By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,524 Members | 1,475 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,524 IT Pros & Developers. It's quick & easy.

Fast sort

P: n/a
Dear all,
what is the best collection for fast sort of small (about 100) data rows.I
want to use collection's sort algorithm, instead of implementing my own.
Thanks,
Boni
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Check out SortedList

"Boni" <oilia@nospam> wrote in message
news:e5***************@TK2MSFTNGP10.phx.gbl...
Dear all,
what is the best collection for fast sort of small (about 100) data rows.I
want to use collection's sort algorithm, instead of implementing my own.
Thanks,
Boni

Nov 21 '05 #2

P: n/a
"Boni" <oilia@nospam> schrieb:
what is the best collection for fast sort of small (about 100) data rows.I
want to use collection's sort algorithm, instead of implementing my own.


'ArrayList.Sort' and 'Array.Sort' are implemented as a quick-sort algorithm,
which is pretty fast for most cases (Theta(n log(n)) for n items).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

P: n/a
Keep in mind though that QuickSort is pretty slow for a collection of items
that are pre-sorted, or nearly sorted, beforehand - worst case O(n ^ 2)
instead of the best case O(n lg n) that Herfried pointed out. With only 100
items it probably won't make a noticeable difference anyway, but keep that
in mind if you add more items to your collection; or if you perform this
sort a bunch of times.

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uf**************@TK2MSFTNGP15.phx.gbl...
"Boni" <oilia@nospam> schrieb:
what is the best collection for fast sort of small (about 100) data
rows.I want to use collection's sort algorithm, instead of implementing
my own.


'ArrayList.Sort' and 'Array.Sort' are implemented as a quick-sort
algorithm, which is pretty fast for most cases (Theta(n log(n)) for n
items).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.