Skip to content

Ordering

Ordering<A> = (a, b) => number

Defined in: Core/Ordering.ts:17

A function that orders two values of type A. Returns a negative number when a comes before b, a positive number when a comes after b, and 0 when they are equal.

Compatible with Array.prototype.sort and Arr.sortWith.

A

A

A

number

type Employee = { name: string; salary: number };

const byName   = pipe(Ordering.string, Ordering.by((e: Employee) => e.name));
const bySalary = pipe(Ordering.number, Ordering.by((e: Employee) => e.salary));

pipe(employees, Arr.sortWith(pipe(byName, Ordering.thenBy(bySalary))));