Javascript: sort string array alphabetically

localeCompare() method can be used:
const array = ['b', 'd', 'c', 'a'];
array.sort((a,b)=>a.localeCompare(b));



see also

No comments:

Post a Comment