If you want to keep the same sort order all the time, you can use SortedList<K,V>
or SortedDictionary<K,V>
and pass to the constructor IComparer<K>
.
If you need a different sort orders in a single container, you can use List<T>
and pass the IComparer<T>
method of Sort
.
Since you are probably storing reference types, I would not worry too much about using elements of both keys and values. You just save the links.
Another option is to implement your own binary tree structure.
source share