RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Classes.TListSortCompare Type

TListSortCompare is a type of callback function called used internally by the TList class.

Pascal
TListSortCompare = function (Item1, Item2: Pointer): Integer;
C++
(Item1, Item2: Pointer): Integer ( TListSortCompare)();

Classes

You define a TListSortCompare function when you need to use the TList Sort method. It is invoked by the internal implementation of the Sort method to sort the TList elements into sequence. This user supplied aspect of the sort process is required since TList is a list of pointers with no inherent sort sequence.  

Item1 and Item2 are 2 elements from the list. When these are passed to the TListSortCompare function, the Sort method is asking which order they should be in. The comparison returns a value determined by the relative values of Item1 and Item2, as shown in this table:  

Value 
Description 
>0 (positive)  
Item1 is less than Item2  
0  
Item1 is equal to Item2  
<0 (negative)  
Item1 is greater than Item2  

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!