Answers for "javscript .sort"

4

javascript order by string array

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

sort arrays according to first array js

itemsArray.sort(function(a, b){  
  return sortingArr.indexOf(a) - sortingArr.indexOf(b);
});
Posted by: Guest on August-17-2020

Browse Popular Code Answers by Language