how to sort javascript object code example
Example 1: sort array of objects javascript
list.sort((a, b) => (a.color > b.color) ? 1 : -1)
Example 2: javascript sort array of objects by key value
arr.sort((x, y) => x.distance - y.distance);
list.sort((a, b) => (a.color > b.color) ? 1 : -1)
arr.sort((x, y) => x.distance - y.distance);