In this Article we will go through how to sort the characters of a string in the alphabetical order only using single line of code in JavaScript.
This is a one-line JavaScript code snippet that uses one of the most popular ES6 features => Arrow Function
.
Let's define this short function:
const sort = str => str.split('').sort((a, b) => a.localeCompare(b)).join('');
sort('hello world'); // dehllloorw