Function arraySortBy

  • Sorts an array in place. This method mutates the array and returns a reference to the same array.

    Type Parameters

    • T
    • K extends string | number | symbol
    • V

    Parameters

    • list: T[]
    • key: K | (item: T) => V

      Function used to determine the order of the elements. It is expected to return a comparable value for this item to sort upon.

      [{size: 11, name: 'John'}, {size: 22, name: 'Max'}].sortBy(obj => obj.name)
      

    Returns T[]

    list (sorting in place)