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.
The whole feed is drained before the first item is emitted, then items are emitted in the order the comparator establishes; equal items keep their relative source order.
Accumulates the whole feed in memory before sorting. For large or infinite feeds, this may exhaust memory or never complete.
The @metreeca/core order module provides helper functions for assembling complex sorting criteria.