Skip to content

by

by<A, B>(f): (ord) => Ordering<B>

Defined in: Core/Ordering.ts:85

Adapts an ordering for type A into an ordering for type B by extracting a field. Read as “ordering by this field”: pipe(Ordering.number, Ordering.by(p => p.price)).

A

B

(b) => A

(ord) => Ordering<B>

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