Answers for "javascript array sort characters"

1

sort an array by characters length in js

arr.sort((a, b) => a.length - b.length)
Posted by: Guest on April-23-2022
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

Code answers related to "Javascript"

Browse Popular Code Answers by Language