Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / May 2006

Tip: Looking for answers? Try searching our database.

dumb question?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
PJ6 - 08 May 2006 20:55 GMT
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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.