Алфавитный массив javaScript
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))
//sort array alphabetically
objArray.sort(function(a, b) {
return a.localeCompare(b);
});
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
}