I have a Collections.Generic.Dictionary(Of Integer, Integer). I want to sort
its contents based on the keys.
Right now the only way I can think of doing this is manually creating a
KeyValuePair array from its contents, sorting it, and then clearing out the
contents and adding them all back in order.
Should I use SortedList instead? Or would that be worse for performance
since it re-sorts on every item add?
Paul
Bob Lehmann - 08 May 2006 23:52 GMT
>> Should I use SortedList instead? Or would that be worse for performance
since it re-sorts on every item add?
What results did your perf testing produce when you compared them?
Bob Lehmann
> I have a Collections.Generic.Dictionary(Of Integer, Integer). I want to sort
> its contents based on the keys.
[quoted text clipped - 7 lines]
>
> Paul
PJ6 - 09 May 2006 14:57 GMT
Fine I'll perf test
>>> Should I use SortedList instead? Or would that be worse for performance
> since it re-sorts on every item add?
[quoted text clipped - 16 lines]
>>
>> Paul
Mattias Sjögren - 08 May 2006 23:57 GMT
>I have a Collections.Generic.Dictionary(Of Integer, Integer). I want to sort
>its contents based on the keys.
Have you considered the SortedDictionary(Of TKey, TValue) class?
Mattias

Signature
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.