I have a key value storage (dictionary) made up of:
key1 value1
key2 value1
key3 value3
key1 value4
key3 value4
and so on
I'd like to group these so the keys only appear once (sorting of keys is optional) and values:
key1 value1, value4
key2 value1
key3 value3, value4
The question: Is there a dedicated way to store the result?
Managed to fix it. Used a key value storage (dictionary) where the keys are key1, key2, key3 and the values are a Set (or Array) of value1, value2, value3 etc.
Something along the line of:
keys do: [ :eachKey | (eachKey condition) ifTrue: [
keyValueStorage at: eachKey ifAbsentPut: [ Set new. ]
( keyValueStorage at: eachKey ) add: value. ] ] .