Re: List<T> sort performance
- From: "Doug Semler" <dougsemler@xxxxxxxxx>
- Date: Sun, 30 Sep 2007 09:23:38 -0400
"Jesper, Denmark" <JesperDenmark@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:96DD23D8-E3A1-40D5-93AC-9F5E2465BBB9@xxxxxxxxxxxxxxxx
Hi,
Can I expect a clever sorting algorithm behind the Sort() function for the
List<T> class? Can't find anything on the net that says anything about this.
While I wouldn't call quicksort particularly "clever" :), I believe that is the algorithm used to sort List<T>. That being said, quicksort is not so good (O(n^2)) if the list is sorted or almost sorted unless the pivot point is randomized (which brings it back to high probability of O(nlgn)), and I don't know that the Framework's implementation does that. So, if your lists fall into this "almost sorted" category (and you are either sorting large lists or sorting lists very often), I would ensure that you profile at some point to make sure you're not spending an inordinate amount of time sorting. If that's the case, you're going to want to either keep the list sorted from the get go or use a different sort implementation.
--
Doug Semler, MCPD
a.a. #705, BAAWA. EAC Guardian of the Horn of the IPU (pbuhh).
The answer is 42; DNRC o-
Gur Hfrarg unf orpbzr fb shyy bs penc gurfr qnlf, abbar rira
erpbtavmrf fvzcyr guvatf yvxr ebg13 nalzber. Fnq, vfa'g vg?
.
- Prev by Date: Re: List<T> sort performance
- Next by Date: Re: Preserve State
- Previous by thread: Re: List<T> sort performance
- Index(es):
Relevant Pages
|
Loading