js sort an array with value of a key code example Example: javascript sort array of objects by key value arr.sort((x, y) => x.distance - y.distance);