Options
All
  • Public
  • Public/Protected
  • All
Menu

Functions to be used in {@link Array.prototype.sort} as a callback.

see

https://pavel-surinin.github.io/declarativejs/#/?id=sorters

Index

Functions

ascendingBy

  • ascendingBy<T>(...getters: function[]): function
  • ascendingBy<T, K>(...keys: K[]): function
  • Functions to be used in {@link Array.prototype.sort} as a callback. Sorts array in ascending order by values provided from callbacks. First callback has highest priority in sorting and so on. It accepts as many callbacks as You need.

    see

    https://pavel-surinin.github.io/declarativejs/#/?id=ascendingby

    Type parameters

    • T

    Parameters

    • Rest ...getters: function[]

      functions to get values to be compared

    Returns function

    a closure that can be used in array.sort() function

      • (a: T, b: T): number
      • Parameters

        • a: T
        • b: T

        Returns number

  • Functions to be used in {@link Array.prototype.sort} as a callback. Sorts array in ascending order by values resolved from object keys passed as parameter. First key has highest priority in sorting and so on. It accepts as many keys as You need.

    see

    https://pavel-surinin.github.io/declarativejs/#/?id=ascendingby

    Type parameters

    • T

    • K: keyof T

    Parameters

    • Rest ...keys: K[]

      functions to get values to be compared

    Returns function

    a closure that can be used in array.sort() function

      • (a: T, b: T): number
      • Parameters

        • a: T
        • b: T

        Returns number

by

  • by<T>(...conditions: SortingCondition<T, any>[]): function
  • by<T, K>(key: K, values: T[K][]): function
  • Functions to be used in {@link Array.prototype.sort} as a callback. Function that will sort items in array with custom values, by provided order. It accepts as a parameter object with valueToOrderElement mapper and array of custom order rule

    type

    T type of array item

    type

    R type of item that will be mapped from callback and will be compared

    see

    https://pavel-surinin.github.io/declarativejs/#/?id=by

    Type parameters

    • T

    Parameters

    Returns function

    comparator for Array.prototype.sort function.

      • (a: T, b: T): number
      • Parameters

        • a: T
        • b: T

        Returns number

  • Functions to be used in {@link Array.prototype.sort} as a callback. Function that will sort items in array with custom values, by provided order.

    see

    https://pavel-surinin.github.io/declarativejs/#/?id=by

    Type parameters

    • T

    • K: keyof T

    Parameters

    • key: K

      object key to extract value. This value will be compared to another

    • values: T[K][]

      values that will be define order of extracted value by key

    Returns function

    comparator for Array.prototype.sort function.

      • (a: T, b: T): number
      • Parameters

        • a: T
        • b: T

        Returns number

descendingBy

  • descendingBy<T>(...getters: function[]): function
  • descendingBy<T, K>(...keys: K[]): function
  • Functions to be used in {@link Array.prototype.sort} as a callback. * Sorts array in descending order by values provided from callbacks. First callback has highest priority in sorting and so on. It accepts as many callbacks as You need.

    see

    https://pavel-surinin.github.io/declarativejs/#/?id=descendingby

    Type parameters

    • T

    Parameters

    • Rest ...getters: function[]

      functions to get values to be compared

    Returns function

    a closure that can be used in array.sort() function

      • (a: T, b: T): number
      • Parameters

        • a: T
        • b: T

        Returns number

  • Functions to be used in {@link Array.prototype.sort} as a callback. Sorts array in descending order by values resolved from object keys passed as parameter. First key has highest priority in sorting and so on. It accepts as many keys as You need.

    see

    https://pavel-surinin.github.io/declarativejs/#/?id=descendingby

    Type parameters

    • T

    • K: keyof T

    Parameters

    • Rest ...keys: K[]

      functions to get values to be compared

    Returns function

    a closure that can be used in array.sort() function

      • (a: T, b: T): number
      • Parameters

        • a: T
        • b: T

        Returns number

orderedBy

  • orderedBy<T>(order: T[]): _orderedBy
  • Functions to be used in {@link Array.prototype.sort} as a callback. Function that will sort items in array, by provided order. It accepts as a parameter array of custom order rule. Element, that are not present in order array will be at he the end of the sorted list.

    see

    https://pavel-surinin.github.io/declarativejs/#/?id=orderedby

    Type parameters

    • T

    Parameters

    • order: T[]

      array of custom order of items that are being sorted.

    Returns _orderedBy

    comparator for Array.prototype.sort function.

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc