I have a Dictionary(Of String, Integer) like so (excuse the lack of a type declaration, all the VB code you see was translated from C#):
I group the given dictionary as so:
The following output is as such:
I have defined my groups and what is inside the groups.
Later on, let's say I have a 2nd Dictionary(Of String, Integer) like so:
I want to be able to do a GroupBy() on this 2nd dictionary, but make sure the Groups created are the same ones as before. The order of the groups can be different (and in some cases, should be), but the content of the groups (the Key portion) must be identical/grouped the same way.
Here's an example output of the 2nd group (as to how I'd like it):
Does anybody have any ideas where the heck I start on this? I can attempt to offer a better explanation if this is not clear enough (and it may not be; I might do a followup post just for clarification).
Code:
Dim baseStatRelation = New Dictionary(Of String, Integer)() From { _
{"HP", 2}, _
{"ATK", 4}, _
{"DEF", 5}, _
{"SPATK", 2}, _
{"SPDEF", 8}, _
{"SPEED", 4} _
}
Code:
Dim groupedBaseRelation = baseStatRelation.OrderByDescending(Function(i) i.Value).GroupBy(Function(i) i.Value).ToList()
Code:
1: [SPDEF, 8]
2: [DEF, 5]
3: [ATK, 4], [SPEED, 4]
4: [HP, 2], [SPATK, 2]
Later on, let's say I have a 2nd Dictionary(Of String, Integer) like so:
Code:
Dim addStatRelation = New Dictionary(Of String, Integer)() From { _
{"HP", 3}, _
{"ATK", 4}, _
{"DEF", 7}, _
{"SPATK", 2}, _
{"SPDEF", 8}, _
{"SPEED", 6} _
}
Here's an example output of the 2nd group (as to how I'd like it):
Code:
1: [SPDEF, 8]
2: [DEF, 7]
3: [SPEED, 6], [ATK, 4]
4: [HP, 3], [SPATK, 2]
Does anybody have any ideas where the heck I start on this? I can attempt to offer a better explanation if this is not clear enough (and it may not be; I might do a followup post just for clarification).