Is there any way to iterate over a Dictionary, in sorted order, sorted by VALUE not key? I did read abut the "SortedDictionary" object, but sadly, that is sorted by key. One solution would be for me to flip all of my keys with my values, and place them into a SortedDictionary (as they are all integers) -- However, I'm not entirely sure how to go with that one either.
Get the pairs of keys/values out, sort them, and iterate. Dead easy using LINQ:
foreach(var pair in dictionary.OrderBy(p => p.Value)) {
// work with pair.Key and pair.Value
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With