Class ComparatorFactory<T>

Defines various methods for constructing comparators.

Type Parameters

  • T

Constructors

Methods

  • Constructs a new comparator where values are ordered by the given comparison function.

    Parameters

    • comparison: ((a, b) => number)
        • (a, b): number
        • Parameters

          Returns number

    Returns Comparator<T>

  • Constructs a new comparator where values are ordered by the natural ascending order of the property selected by the given selector function.

    Parameters

    • selector: ((value) => any)
        • (value): any
        • Parameters

          • value: T

          Returns any

    Returns Comparator<T>

  • Constructs a new comparator where values are ordered by the natural ascending order of values for the given key.

    Parameters

    • key: keyof NonNullable<T>

    Returns Comparator<T>

  • Constructs a new comparator where values are ordered by the natural descending order of the property selected by the given selector function.

    Parameters

    • selector: ((value) => any)
        • (value): any
        • Parameters

          • value: T

          Returns any

    Returns Comparator<T>

  • Constructs a new comparator where values are ordered by the natural descending order of values for the given key.

    Parameters

    • key: keyof NonNullable<T>

    Returns Comparator<T>