You can simply change your SortedDictionary<TKey, TValue> to SortedList<TKey, TValue> , and then use IndexOfKey(key) :
var s = new SortedList<string, string> { { "a", "Ay" }, { "b", "Bee" }, { "c", "Cee" } };
IndexOfKey internally uses Array.BinarySearch<TKey>() , so it will be O (log n), which is faster than O (n) (which would be if you were looking back first by iterating through it).
Timwi
source share