Function sort

  • Returns an array containing the values in the given iterable in the sorted order defined by the given comparator function. If comparator is not specified, it defaults to d3.ascending. Equivalent to array.sort, except that it does not mutate the given iterable, and the comparator defaults to natural order instead of lexicographic order.

    Type Parameters

    • T

    Parameters

    • iterable: Iterable<T>
    • Optional comparator: ((a, b) => number)
        • (a, b): number
        • Parameters

          • a: T
          • b: T

          Returns number

    Returns T[]

  • Returns an array containing the values in the given iterable in the sorted order defined by the given accessor function. This is equivalent to a comparator using natural order. The accessor is only invoked once per element, and thus may be nondeterministic. Multiple accessors may be specified to break ties.

    Type Parameters

    • T

    Parameters

    • iterable: Iterable<T>
    • Rest ...accessors: ((a) => unknown)[]

    Returns T[]