New to dart, with origin from python. One thing I cannot find native support for is to be able to group an Iterable by a defined key. In python there is a very nice support from the itertools package (https://docs.python.org/3.8/library/itertools.html#itertools.groupby). What I want to achieve can be described in pseudo code.
a = [
{
x: 1,
y: 1,
},
{
x: 1,
y: 2,
},
{
x: 2,
y: 3,
},
{
x: 2,
y: 4,
}
]
for group, items in groupby(a, key: item['x']):
print('$group : $items')
Expected output:
1 : {x:1, y: 1}, {x:1, y:2}
2 : {x:2, y: 3}, {x:2, y:4}