[fpc-devel] TStringList.CustomSort

Micha Nelissen micha at neli.hopto.org
Tue Nov 7 10:17:24 CET 2006

Chris Cheney wrote:
> Stating the obvious: but the programmer might wish to sort by the objects 
> or by some combination of the strings and the objects (or even by entries 
> in an external array, unrelated to the StringList) - the indexes are 
> therefore needed in the general case.

Oh right, sorting by object contents. Seems strange to me, but perhaps 
useful, indeed.

> 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.


More information about the fpc-devel mailing list