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
 
PREVIOUS NEXT
Tagged: #js #sort #string #array
ADD COMMENT
Topic
Name
8+8 =