'How to get the key of the first max value in a C# Dictionary?
I want to get the keys of the highest values in a dictionary {'a' : 1, 'b' : 2, 'c' : 2}. In this case I want it to return 'b' but use of
weight.Aggregate((l, r) => l.Value > r.Value ? l : r).Key;
returns the last largest value i.e. 'c'.
- Is there a way to return the key of the first largest value in my dictionary? =>
'b' - Also, is it possible to return an array of keys of the max tied values? =>
new char[]{'b', 'c'} - Which Key-Value data structure should I use instead?
EDIT: Since it has caused quite a stir in the comments, I mean the first largest value in terms of insertion order.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
