Answers for "sort letters of string into alphabetically javascript"

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
0

javascript hot to sort letters

const sort = str => str.split('').sort((a, b) => a.localeCompare(b)).join('');

// Example:
sort('eat'); 
// Output:
// 'aet'
Posted by: Guest on October-25-2021

Code answers related to "sort letters of string into alphabetically javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language