My Tech Notes
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
comparing 2 strings alphabetically for sorting purposes
No comments:
Post a Comment
‹
›
Home
View web version
No comments:
Post a Comment