Answers for "sort array of letters in javascript"

4

javascript sort chars in string

const sort = str => str.split('').sort((a, b) => a.localeCompare(b)).join('');

// Example
sort('hello world');    // dehllloorw
Posted by: Guest on July-03-2020
2

javascript sort array strings alphabetically

//sort array alphabetically
objArray.sort(function(a, b) {
   return a.localeCompare(b);
});
Posted by: Guest on September-23-2020

Code answers related to "sort array of letters in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language