C# Iterate over Dictionary sorted by value
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
}
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
}