Options
All
  • Public
  • Public/Protected
  • All
Menu

Sorting routines

Index

Variables

Const Sort

Sort: { byName: SortFn<Named<"scenario" | "incomeStream" | "asset" | "liability" | "income" | "expense" | "incomeTax" | "person" | "text">>; byRate: SortFn<any>; byStart: SortFn<any>; byType: SortFn<Named<"scenario" | "incomeStream" | "asset" | "liability" | "income" | "expense" | "incomeTax" | "person" | "text">>; byValue: SortFn<any>; natural: <T>(a: T, b: T) => 0 | 1 | -1; null: <T>(a: T, b: T) => 0 | 1 | -1 } = ...

Collection of sort comparator functions.

Type declaration

  • byName: SortFn<Named<"scenario" | "incomeStream" | "asset" | "liability" | "income" | "expense" | "incomeTax" | "person" | "text">>
  • byRate: SortFn<any>
  • byStart: SortFn<any>
  • byType: SortFn<Named<"scenario" | "incomeStream" | "asset" | "liability" | "income" | "expense" | "incomeTax" | "person" | "text">>
  • byValue: SortFn<any>
  • natural: <T>(a: T, b: T) => 0 | 1 | -1
      • <T>(a: T, b: T): 0 | 1 | -1
      • A comparator that sorts according to the "natural" order. First by type, then by string or numerical ordering if a string, number, boolean, or symbol.

        Type parameters

        • T

        Parameters

        • a: T
        • b: T

        Returns 0 | 1 | -1

  • null: <T>(a: T, b: T) => 0 | 1 | -1
      • <T>(a: T, b: T): 0 | 1 | -1
      • A comparator that does not alter the sort order. It regards everything as equal, and thus Javascript's stable sort leaves the ordering unchanged.

        Type parameters

        • T

        Parameters

        • a: T
        • b: T

        Returns 0 | 1 | -1

        0

Const comparator

comparator: typeof comparator = ...

Functions

Const composeSorts

  • Compose multiple sort functions into one.

    Type parameters

    • T

    Parameters

    • fn: SortFn<T>

      The first sort function

    • Rest ...fns: SortFn<T>[]

      Additional sort functions to compose, if the previous return 0 for equality.

    Returns SortFn<T>

Const invertSort

  • Invert the direction of sorting of a sort comparator function.

    Type parameters

    • T

    Parameters

    • fn: SortFn<T>

      A sort comparator function

    Returns SortFn<T>

    A sort comparator function that sorts in the opposite direction

Const makeSort

  • makeSort<T>(cmp?: SortFn<T>): <I>(l: Iterable<I>) => I[]
  • A higher-order function that returs a sort function.

    Type parameters

    • T

    Parameters

    • cmp: SortFn<T> = ...

      a comparator

    Returns <I>(l: Iterable<I>) => I[]

    a sort function that sorts a list according to cmp

      • <I>(l: Iterable<I>): I[]
      • Type parameters

        • I

        Parameters

        • l: Iterable<I>

        Returns I[]

Const naturalCMP

  • naturalCMP<T>(a: T, b: T): 0 | 1 | -1
  • A comparator that sorts according to the "natural" order. First by type, then by string or numerical ordering if a string, number, boolean, or symbol.

    Type parameters

    • T

    Parameters

    • a: T
    • b: T

    Returns 0 | 1 | -1

Const naturalSort

  • naturalSort<I>(l: Iterable<I>): I[]
  • A function that sorts according to natural order. See naturalCMP.

    Type parameters

    • I: unknown

    Parameters

    • l: Iterable<I>

    Returns I[]

    a copy of list in sorted order.

Const nullCMP

  • nullCMP<T>(a: T, b: T): 0 | 1 | -1
  • A comparator that does not alter the sort order. It regards everything as equal, and thus Javascript's stable sort leaves the ordering unchanged.

    Type parameters

    • T

    Parameters

    • a: T
    • b: T

    Returns 0 | 1 | -1

    0

Const sortBy

  • sortBy<T, V>(field: T): SortFn<V>
  • Type parameters

    • T: string | number | symbol

    • V: {[ K in string | number | symbol]: any }

    Parameters

    • field: T

    Returns SortFn<V>

Generated using TypeDoc