Answers for "function returns an array alphabetically ordered js"

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
1

javascript string array sort alphabetically

var items = ['réservé', 'premier', 'communiqué', 'café', 'adieu', 'éclair'];
items.sort((a, b) =>
   a.localeCompare(b)//using String.prototype.localCompare()
);
Posted by: Guest on August-12-2020

Code answers related to "function returns an array alphabetically ordered js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language