reverseSortFn
Reverses the order of a sort function: reverseSortFn(fn)(a, b) is fn(b, a).
Gives a descending variant of any comparator, including the ones built by the
createSortBy*Fn factories, and composes with combineSortFns for mixed orders.
Ties stay ties, so the sort remains stable.
Available since v3.1.4
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
fn | SortFn<T> | The sort function to reverse |
Returns
Section titled “Returns”SortFn<T> — A sort function with the opposite order
Examples
Section titled “Examples”Newest first
Section titled “Newest first”Turns an ascending comparator into a descending one.
Mixed order
Section titled “Mixed order”Newest first, then name ascending, by combining it with combineSortFns.
Related Types
Section titled “Related Types”SortFn
Section titled “SortFn”Sort function type for arrays
