Answers for "javascript compare and sort strings alphabetically"

3

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
2

javascript sort array strings alphabetically

//sort array alphabetically
objArray.sort(function(a, b) {
   return a.localeCompare(b);
});
Posted by: Guest on September-23-2020
-1

javascript compare and sort strings alphabetically

function sortString(str){
  var arr = str.split('');
  var sorted = arr.sort();
  return sorted.join('');
}Copy
Posted by: Guest on February-29-2020

Code answers related to "javascript compare and sort strings alphabetically"

Code answers related to "Javascript"

Browse Popular Code Answers by Language