sort string characters javascript code example
Example 1: javascript sort chars in string
const sort = str => str.split('').sort((a, b) => a.localeCompare(b)).join('');
// Example
sort('hello world'); // dehllloorw
Example 2: sort a string in javascript
var string='ACBacb';
var sortedString = string.split('').sort().join('');