When to use a SortedList over a SortedDictionary?

I’m not sure how accurate the MSDN documentation is on SortedList and SortedDictionary. It seems to be saying both are implemented using a binary search tree. But if the SortedList uses a binary search tree, why would it be much slower on additions than SortedDictionary? Anyway, here are some performance test results. Each test operates … Read more

C# Sortable collection which allows duplicate keys

Use your own IComparer! Like already stated in some other answers, you should use your own comparer class. For this sake I use a generic IComparer class, that works with anything that implements IComparable: /// <summary> /// Comparer for comparing two keys, handling equality as beeing greater /// Use this Comparer e.g. with SortedLists or … Read more

What’s the difference between SortedList and SortedDictionary?

Yes – their performance characteristics differ significantly. It would probably be better to call them SortedList and SortedTree as that reflects the implementation more closely. Look at the MSDN docs for each of them (SortedList, SortedDictionary) for details of the performance for different operations in different situtations. Here’s a nice summary (from the SortedDictionary docs): … Read more