Function qsort

  • Sorts the array in-place using an optional comparator and invokes a callback after a pair of elements was swapped.

    swap or comparator callbacks are guaranteed to be called after the elements of arr are swapped.

    Type Parameters

    Parameters

    • arr: T

      The mutable array-like data structure that is sorted in-place.

    • Optionalswap: ((i: number, j: number) => void)

      The callback that is invoked with indices that were swapped.

        • (i, j): void
        • Parameters

          • i: number
          • j: number

          Returns void

    • Optionalcomparator: Comparator<ArrayValue<T>>

      The callback that defines the sort order. If omitted, the array elements are compared using comparison operators.

    Returns T

    The input array.