Skip to content

sortWith

sortWith<A>(ord): (data) => readonly A[]

Defined in: Data/Arr.ts:382

Sorts an array using an Ordering<A>. Returns a new array without mutating the original. Use this over sortBy when you have a typed Ordering<A> from the Ordering module.

A

Ordering<A>

(data) => readonly A[]

pipe([3, 1, 2], Arr.sortWith(Ordering.number)); // [1, 2, 3]

const byPrice = pipe(Ordering.number, Ordering.by((p: Product) => p.price));
pipe(products, Arr.sortWith(byPrice));