1// Alphabetically
2const ascending = data.sort((a, b) => a[field].localeCompare(b[field]))
3// Descending
4const descending = ascending.reverse()
5
1//sort array alphabetically
2objArray.sort(function(a, b) {
3 return a.localeCompare(b);
4});
1function sortString(str){
2 var arr = str.split('');
3 var sorted = arr.sort();
4 return sorted.join('');
5}Copy