Answers for "sort alphabetically javascript es6"

16

alphabetical order array javascript

arr.sort(function(a, b) {
    return a === b ? 0 : a < b ? -1 : 1;
  });
Posted by: Guest on August-11-2020
10

js sort alphabetically

users.sort((a, b) => a.firstname.localeCompare(b.firstname))
Posted by: Guest on October-19-2020
3

js sort alphabetically

users.sort(function(a, b){
    if(a.firstname < b.firstname) { return -1; }
    if(a.firstname > b.firstname) { return 1; }
    return 0;
})
Posted by: Guest on July-13-2021

Code answers related to "sort alphabetically javascript es6"

Code answers related to "Javascript"

Browse Popular Code Answers by Language