I want to sort a dictonary by its key but all the other answers involved making a list and adding it to that. It there a way to sort the dictonary itself and move the keys along with the corresponding value? Example:
Dictonary<int, int> dict = new Dictionary<int, int>();
dict.Add(0, 1);
dict.Add(5, 4);
dict.Add(2, 7);
dict.Add(7, 9);
dict.Add(1, 2);
dict.Add(4, 0);
then make the dictonary equal
0, 1
1, 2
2, 7
4, 0
5, 4
7, 9