Returns <
T extends object,
Fields extends string,
Sortable extends
(`-${Fields}` | `+${Fields}`)[] = (`-${Fields}` | `+${Fields}`)[],
>(
getter: (sortable: Sortable) => Promise<T[]>,
) => (
...fields: Fields[],
) => (
comp: (x: T, y: T) => number,
filter?: (elem: T) => boolean,
) => (direction: "+" | "-", trace?: boolean) => Promise<void>
A currying function chain: API getter, field names, comparator,
then direction
Validates sorting functionality of pagination APIs.
Tests sorting operations by calling the API with sort parameters and validating that results are correctly ordered. Supports multiple fields, ascending/descending order, and optional filtering. Provides detailed error reporting for sorting failures.
Example
Throws
Error when API results are not properly sorted according to specification