You can sort arrays of objects. In this case we leverage the collator.compare
method and pass along the properties that we want to sort by.
let objects = [
{ name: "nop", value: 3 },
{ name: "NOP", value: 2 },
{ name: "ñop", value: 1 },
{ name: "abc", value: 3 },
{ name: "abc", value: 2 },
{ name: "äbc", value: 1 },
];
const collator = new Intl.Collator('en');
objects.sort((a, b) => collator.compare(a.name, b.name));
console.log(objects);
/*
[
{ "name": "abc", "value": 3 },
{ "name": "abc", "value": 2 },
{ "name": "äbc", "value": 1 },
{ "name": "nop", "value": 3 },
{ "name": "NOP", "value": 2 },
{ "name": "ñop", "value": 1 }
]
*/