Syntax: groupBy ()
Groups the elements of a sequence by its keys.
Syntax: groupBy (keySelector {(v, k) ==> key})
Groups the elements of a sequence according to a specified key selector function.
Syntax: groupBy (keySelector {(v, k) ==> key}, valueSelector {(v, k) ==> value})
Groups the elements of a sequence according to a specified key selector function and projects the elements for each group by using a specified function.
Syntax: groupBy (keySelector {(v, k) ==> key}, valueSelector {(v, k) ==> value}, resultSelectorValue {(e, k) ==> value} [, resultSelectorKey {(e, k) ==> key}])
Groups the elements of a sequence according to a specified key selector function and creates a result value from each group and its key.
For all overloads except the last: the groupBy method returns a sequence of sequences, one inner sequence for each distinct key that was encountered. The outer sequence is yielded in an order based on the order of the elements in source that produced the first key of each inner sequence. Elements in a inner sequence are yielded in the order they appear in source.
public groupBy ( callable | null $keySelector = null, callable | null $valueSelector = null, callable | null $resultSelectorValue = null, callable | null $resultSelectorKey = null ) : |
||
$keySelector | callable | null | {(v, k) ==> key} A function to extract the key for each element. Default: key. |
$valueSelector | callable | null | {(v, k) ==> value} A function to map each source element to a value in the inner sequence. |
$resultSelectorValue | callable | null | {(e, k) ==> value} A function to create a result value from each group. |
$resultSelectorKey | callable | null | {(e, k) ==> key} A function to create a result key from each group. |
return | A sequence of sequences indexed by a key. |