[fpc-devel] TStringList.CustomSort
    Vinzent Hoefler 
    JeLlyFish.software at gmx.net
       
    Tue Nov  7 10:29:55 CET 2006
    
    
  
On Tuesday 07 November 2006 09:17, Micha Nelissen wrote:
> Chris Cheney wrote:
>
> > Of course, the efficient way to build a sorted list is to set
> > Sorted to False and to sort the list after all the items have been
> > added.
>
> It doesn't matter in O-time: both are O(n log n). Nevertheless, you
> probably will save some function call overhead.
That highly depends on the sorting algorithm used. A plain Quicksort has 
a very bad worst case of O(n**2) that develops especially when the list 
to be sorted already is. Even Bubblesort would be faster in such a 
case.
Vinzent.
    
    
More information about the fpc-devel
mailing list