sort by object attribute code example
Example: sort by object property javascript
let list = [
{
name: "world"
},
{
name: "hello",
},
];
// This doesn't account for if names are the same between objects
let x = list.sort((a, b) => (a.name > b.name ? 1 : -1));
console.log(x);
/*
[
{
name: "hello",
},
{
name: "world"
},
];
*/