Options
All
  • Public
  • Public/Protected
  • All
Menu

Module array/sortBy

Index

References

Functions

References

Renames and re-exports sortBy

Functions

  • sortBy<T, R>(fn: OrdFunc<T, R>, list: ArrayLike<T>): T[]
  • sortBy<T, R>(fn: OrdFunc<T, R>): (list: ArrayLike<T>) => T[]
  • Sorts the array according to the supplied function.

    example
     var sortByFirstItem = sortBy(x => x[0]);
    var pairs = [[-1, 1], [-2, 2], [-3, 3]];
    sortByFirstItem(pairs); //=> [[-3, 3], [-2, 2], [-1, 1]]

    Type parameters

    Parameters

    • fn: OrdFunc<T, R>
    • list: ArrayLike<T>

    Returns T[]

    A new array sorted by the keys generated by fn.

  • Sorts the array according to the supplied function.

    example
     var sortByFirstItem = sortBy(x => x[0]);
    var pairs = [[-1, 1], [-2, 2], [-3, 3]];
    sortByFirstItem(pairs); //=> [[-3, 3], [-2, 2], [-1, 1]]

    Type parameters

    Parameters

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

    A new array sorted by the keys generated by fn.

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

        • list: ArrayLike<T>

        Returns T[]

Generated using TypeDoc