Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js sort string array

const sort = (arr) => arr.slice().sort(); // default sort
const sort = (arr) => arr.slice().sort((a, b) => a - b); // simple sort
const sort = (arr) => arr.slice().sort((a, b) => a.localeCompare(b, 'en', { sensitivity: 'base' })); // language-specific sort
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #sort #string #array
ADD COMMENT
Topic
Name
1+5 =