• Groups the elements of an array based on the given function and returns the count of elements in each group

    Example

    sortBy(['five', 'three', 'one'], 'length'); // ['one', 'five', 'three']
    

    Example

    sortBy(['five', 'three', 'one'], (value) => -value.length); // ['three', 'five', 'one']
    

    Type Parameters

    • T

    Parameters

    • arr: T[]
    • fn: string | ((value: T) => number)

    Returns T[]

Generated using TypeDoc