System.Classes.TListSortCompare

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

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

C++

typedef int __fastcall (*TListSortCompare)(void * Item1, void * Item2);

Properties

Type Visibility Source Unit Parent
type
typedef
public
System.Classes.pas
System.Classes.hpp
System.Classes System.Classes

Description

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

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 greater than Item2

0

Item1 is equal to Item2

<0 (negative)

Item1 is less than Item2



See Also

Code Examples