Create a comparator that sorts by the value at the given object property, using compareFn to compare those values.
property
compareFn
[{ age: 30 }, { age: 20 }].sort(byProperty(bySubtraction, 'age')); // [{ age: 20 }, { age: 30 }] Copy
[{ age: 30 }, { age: 20 }].sort(byProperty(bySubtraction, 'age')); // [{ age: 20 }, { age: 30 }]
Create a comparator that sorts by the value at the given object
property, usingcompareFnto compare those values.