Function sort

  • Return a new sorted array from the passed-in iterable. This function internally calls the Array.sort method, passing comparator.

    Type Parameters

    • Iter extends AnyIt<unknown>
    • V extends unknown

    Parameters

    • iter: Iter
    • comparator: Comparator<V>

    Returns AnyItResult<Iter, V[]>

    An array.

    Example

    // Returns [1, 2, 3]
    it.reduce([3, 1, 2], (a, b) => a - b)