• Sorts an array of items into groups. The return value is a map where the keys are the group ids the given getGroupId function produced and the value is an array of each item in that group.

    Type Parameters

    • T
    • Key extends string | number | symbol

    Parameters

    • array: readonly T[]
    • getGroupId: ((item) => Key)
        • (item): Key
        • Parameters

          • item: T

          Returns Key

    Returns Partial<Record<Key, T[]>>