Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to sort string alphabetically in javascript

// Alphabetically
const ascending = data.sort((a, b) => a[field].localeCompare(b[field]))
// Descending
const descending = ascending.reverse()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sort #string #alphabetically #javascript
ADD COMMENT
Topic
Name
8+2 =