Sort the characters of a string in the alphabetical order
JavaScript
const sort = (str) => str
.split('')
.sort((a, b) => a.localeCompare(b))
.join('')
Examples
sort('hello world') // dehllloorw
const sort = (str) => str
.split('')
.sort((a, b) => a.localeCompare(b))
.join('')
sort('hello world') // dehllloorw