Class Sorter<Entity>

Entity Array Sorter

Sorting functions sort the array in place and also return the sorted array.

Type Parameters

  • Entity extends Object

Hierarchy

  • Sorter

Constructors

  • Type Parameters

    • Entity extends Object

    Parameters

    • array: Entity[]

    Returns Sorter<Entity>

Properties

array: (Entity & {
    [k: string]: any;
})[]
collator: Collator = ...
comparator: undefined | ((a, b) => number) = undefined

Type declaration

    • (a, b): number
    • Parameters

      • a: any
      • b: any

      Returns number

sortParent: null | string = null
sortProperty: null | string = null

Methods

  • Parameters

    • a: Entity & {
          [k: string]: any;
      }
    • b: Entity & {
          [k: string]: any;
      }

    Returns number

  • Sort an array of entities hierarchically by a specified property's value.

    Entities will be placed immediately after their parents. The parentProperty property, if present, should hold either null, undefined, or the entity's parent.

    Parameters

    • property: string

      The name of the property to sort entities by.

    • parentProperty: string

      The name of the property which holds the parent of the entity.

    • Optional sortOptions: SortOptions

    Returns Entity[]

  • Sort an array of entities by parent and a specified property's value.

    Entities' will be sorted by their parents' properties, then the entities' properties.

    Parameters

    • property: string

      The name of the property to sort entities by.

    • parentProperty: string

      The name of the property which holds the parent of the entity.

    • __namedParameters: SortOptions = {}

    Returns Entity[]

  • Sort an array of entities by a specified property's value.

    Parameters

    • property: string

      The name of the property to sort entities by.

    • __namedParameters: SortOptions = {}

    Returns Entity[]

Generated using TypeDoc