import { struct } from "https://deno.land/x/fun@v2.0.0-alpha.6/ord.ts";
Derives an Ord from a structs of Ords. The derived Ord will compare two structs starting with the first defined key and return the first ordering that is non-zero, otherwise the two structs are equal.
Examples
Example 1
Example 1
import { struct, lt } from "./ord.ts"
import { OrdNumber } from "./number.ts";
import { OrdString } from "./string.ts";
import { pipe } from "./fn.ts";
const ord = struct({ num: OrdNumber, str: OrdString });
const _lt = lt(ord);
const result1 = pipe(
{ num: 1, str: "a" },
_lt({ str: "b", num: 2 })
); // true
const result2 = pipe(
{ num: 1, str: "a" },
_lt({ str: "b", num: 1 })
); // true
const result3 = pipe(
{ num: 1, str: "a" },
_lt({ str: "a", num: 1 })
); // false