Is there a sorted collection type in .NET?
.net, c#, containers, sorting
Solution
You might want to take a look at the Wintellect Power Collections. It is available on CodePlex and contains quite a few collections that are very helpful. The OrderedBag collection in the project is exactly what you are looking for. It essentially uses a red-black tree to provide a pretty efficient sort.
Problem
I'm looking for a container that keeps all its items in order. I looked at SortedList, but that requires a separate key, and does not allow duplicate keys. I could also just use an unsorted container and explicitly sort it after each insert. Usage: - Occasional insert - Frequent traversal in order - Ideally not working with keys separate from the actual object, using a compare function to sort. - Stable sorting for equivalent objects is desired, but not required. - Random access is not required. I realize I can just build myself a balanced tree structure, I was just wondering if the framework already contains such a beast.