Groups each item in the array of items into a map according to the keySelector
There are two overloads:
groupBy(items, keySelector) – groups the original items using the key returned by
keySelector.groupBy(items, keySelector, valueSelector) – groups transformed values using the key returned
by keySelector and the value returned by valueSelector.valueSelector is an optional third parameter. It is a function that runs on each item to get
the value to store in the group. The first argument is the item, the second argument is the key
for the group to which this item belongs, and the third argument is the index of the item in the
original array. If valueSelector is not provided, the original item is used in the resulting
groups.
Array of items to group by.
Function to run on each item to get the key for the group to which it belongs. The first argument is the item, and the second argument is the index of the item in the original array.
Map of keys to groups of values corresponding to each item.
Groups each item in the array of items into a map according to the keySelector
There are two overloads:
groupBy(items, keySelector)– groups the original items using the key returned bykeySelector.groupBy(items, keySelector, valueSelector)– groups transformed values using the key returned bykeySelectorand the value returned byvalueSelector.valueSelectoris an optional third parameter. It is a function that runs on each item to get the value to store in the group. The first argument is the item, the second argument is the key for the group to which this item belongs, and the third argument is the index of the item in the original array. IfvalueSelectoris not provided, the original item is used in the resulting groups.