JavaScript array ordo abjad
arr.sort(function(a, b) {
return a === b ? 0 : a < b ? -1 : 1;
});
Yawning Yacare
arr.sort(function(a, b) {
return a === b ? 0 : a < b ? -1 : 1;
});
users.sort((a, b) => a.firstname.localeCompare(b.firstname))
// Alphabetically
const ascending = data.sort((a, b) => a[field].localeCompare(b[field]))
// Descending
const descending = ascending.reverse()
users.sort((a, b) => a.firstname.localeCompare(b.firstname))
const str = 'sorting'; //sorting a string
str.split('').sort().join(''); //output: ginorst
function alphabetized(s) {
var ans="";
for (var i=97; i<123; ++i)
for (var j=0; j<s.length; j++)
if (s[j].toLowerCase().charCodeAt()==i)
ans+=s[j]
return ans
}