group multimethod

Methods

group(e:Eachable1, k:Fun, v:Fun=method) Source: stdlib.ngs:4106
Group items from e by key returned by k

Returns

Hash with Arr values

Example

["ab", "ac", "ba", "bc", "bd"].group(F(x) x[0])  # {a=[ab,ac], b=[ba,bc,bd]}
[["a", 1], ["b", 2], ["a", 3]].group(X[0], X[1])  # {"a": [1,3], "b": [2]}
group(e:Eachable1, field:Str) Source: stdlib.ngs:4116
Group items from e by the given field

Returns

Hash with Arr values

Example

[{"id": 100, "a": 1}, {"id": 200, "a": 2}, {"id": 300, "a": 2}].group("a")  # {1=[{id=100, a=1}], 2=[{id=200, a=2},{id=300, a=2}]}