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;
});
function alphabeticalOrder(arr) {
return arr.sort((a, b) => a < b ? -1 : 1)
}
alphabeticalOrder(["a", "d", "c", "a", "z", "g"]);
// [ 'a', 'a', 'c', 'd', 'g', 'z' ]
// Alphabetically
const ascending = data.sort((a, b) => a[field].localeCompare(b[field]))
// Descending
const descending = ascending.reverse()
var items = ['réservé', 'premier', 'communiqué', 'café', 'adieu', 'éclair'];
items.sort((a, b) =>
a.localeCompare(b)//using String.prototype.localCompare()
);
acggcdf
vxcxbbbxbb