The type of items in the feed
A task yielding the items of the feed in comparator order
await pipe(
(items([3, 1, 2]))
(sort())
(toArray())
); // [1, 2, 3]
await pipe(
(items([3, 1, 2]))
(sort(descending))
(toArray())
); // [3, 2, 1]
await pipe(
(items([{ age: 30 }, { age: 20 }]))
(sort(by(x => x.age)))
(toArray())
); // [{ age: 20 }, { age: 30 }]
await pipe(
(items(["Émile", "Alice"]))
(sort((a, b) => a.localeCompare(b)))
(toArray())
); // ["Alice", "Émile"]
Creates a task reordering the feed.
Items are emitted in the order the comparator establishes; equal items keep their relative source order.
The order module of
@metreeca/coreprovides helper functions for assembling complex sorting criteria.