how to sort array of objects based on value of keys in objects in javascript code example
Example 1: javascript sort array of objects by key value
arr.sort((x, y) => x.distance - y.distance);
Example 2: sort array of objects javascript by key value
myArray.sort(function(a, b) {
return a.distance - b.distance;
});