Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to sort string alphabetically in javascript

    *************sort String*************

1.    arr.sort(function(a, b) {
    return a === b ? 0 : a < b ? -1 : 1;
  });

**************************************************************
 2.    users.sort((a, b) => a.firstname.localeCompare(b.firstname))    // Anuj Kashyap
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #sort #string #alphabetically #javascript
ADD COMMENT
Topic
Name
9+9 =