Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

sort string mixed with numbers javascript

const sortAlphaNum = (a, b) => a.localeCompare(b, 'en', { numeric: true })
console.log(['A1', 'A10', 'A11', 'A12', 'A2', 'A3', 'A4', 'B10', 'B2', 'F1', 'F12', 'F3'].sort(sortAlphaNum))
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sort #string #mixed #numbers #javascript
ADD COMMENT
Topic
Name
4+2 =