Rest
...comparators: Tused in order to compare values
a new comparator that uses the given comparators
const list = [
{ foo: "bbb", bar: "yyy" },
{ foo: "aaa", bar: "xxx" },
{ foo: "bbb", bar: "xxx" },
];
// sorts the list comparing by "foo" and then by "bar"
list.sort(
compareWith(
compareBy("foo"),
compareBy("bar"),
)
);
// Result:
// [
// { foo: "aaa", bar: "xxx" },
// { foo: "bbb", bar: "xxx" },
// { foo: "bbb", bar: "yyy" },
// ]
Creates a comparator from an ordered list of comparators.
The returned comparator calls each given comparator in order until one determines the values are not equal.