Answers for "array sort for letters js"

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
1

sort arrays according to first array js

itemsArray.sort(function(a, b){  
  return sortingArr.indexOf(a) - sortingArr.indexOf(b);
});
Posted by: Guest on August-17-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language