My Tech Notes
Search This Blog
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
Newer Post
Older Post
Home
View mobile version
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment