" Live as if you were to die tomorrow. Learn as if you were to live forever.. "
- Mahatma Gandhi
Here is a function using LINQ to sort a dictionary by value.
public static Dictionary<int, int> SortDictionaryByValue(Dictionary<int, int> data)
List<KeyValuePair<int, int>> li = newList<KeyValuePair<int, int>>(data);
li.Sort((x, y) => x.Value.CompareTo(y.Value));
return li.ToDictionary(p => p.Key, p => p.Value);
Mail (will not be published) (required)
Enter Captcha Code *
× four = 28
Burn Ignorance is a knowledge initiative by Mindfire Solutions
Subscribe to our mailing list to get the updates to your email inbox...