Get a KeyValuePair list or array from a dictionary

Dictinary<int,int> myDict = new Dictionary<int,int>();

What can I do to get a list of the KeyValue pairs of the dictionary (I want to sort them on Values)?

From what I can see there is no way to do this. You can only get the keys or values separately! Or an enumarator, is that the only way?

This is super old but just posting this if anyone else needs it (this came up in google for me)

For me, this worked

Dictionary<int,float> myDict = new Dictionary<int,float>();

private List<KeyValuePair<int,float>> GetKeyValuePairs() {
    List<KeyValuePair<int,float>> keyValuePairs = new List<KeyValuePair<int,float>>();
    foreach (KeyValuePair<int,float> kvp in myDict) {
    return keyValuePairs;

Or replace int,float with whatever you want. KeyValuePairs have to be initialized with the same datatypes as the dictionary that they’re reading from.