Answers for "how to sort array of words in alphabetical order in javascript"

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
4

js order alphabetically

// Alphabetically
const ascending = data.sort((a, b) => a[field].localeCompare(b[field]))
// Descending
const descending = ascending.reverse()
Posted by: Guest on November-05-2020

Code answers related to "how to sort array of words in alphabetical order in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language