Options
All
  • Public
  • Public/Protected
  • All
Menu

Module array/sort

Index

References

Functions

References

Renames and re-exports sort

Functions

  • sort<T, R>(fn: CompareFunc<T, R>, list: ArrayLike<T>): T[]
  • sort<T, R>(fn: CompareFunc<T, R>): (list: ArrayLike<T>) => T[]
  • Returns a copy of the array, sorted according to the comparator function, which should accept two values at a time and return a negative number if the first value is smaller, a positive number if it's larger, and zero if they are equal. Please note that this is a copy of the list. It does not modify the original.

    example
     var diff = function(a, b) { return a - b; };
    sort(diff, [4,2,7,5]); //=> [2, 4, 5, 7]

    Type parameters

    Parameters

    Returns T[]

    a new array with its elements sorted by the comparator function.

  • Returns a copy of the array, sorted according to the comparator function, which should accept two values at a time and return a negative number if the first value is smaller, a positive number if it's larger, and zero if they are equal. Please note that this is a copy of the list. It does not modify the original.

    example
     var diff = function(a, b) { return a - b; };
    sort(diff, [4,2,7,5]); //=> [2, 4, 5, 7]

    Type parameters

    Parameters

    Returns (list: ArrayLike<T>) => T[]

    a new array with its elements sorted by the comparator function.

      • (list: ArrayLike<T>): T[]
      • Parameters

        • list: ArrayLike<T>

        Returns T[]

Generated using TypeDoc