RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
WideStrings.TWideStringListSortCompare Type

TWideStringListSortCompare is a type of callback function called used internally by the TWideStringList class.

Pascal
TWideStringListSortCompare = function (List: TWideStringList; Index1, Index2: Integer): Integer;
C++
(List: TWideStringList; Index1, Index2: Integer): Integer ( TWideStringListSortCompare)();

You define a TWideStringListSortCompare function when you need to use the TWideStringList CustomSort method. The procedure defined by TWideStringListSortCompare is invoked by CustomSort to sort the TWideStringList elements into sequence.  

CustomSort is used instead of Sort when the sort sequence required differs from the default alphanumeric sequence.  

List is the list of Unicode strings. 

Index1 and Index2 are indexes into the list. When these are passed to the TListSortCompare function, the CustomSort method is asking which order they should be in.  

You return 0 if the entry referred to by Index1 equals the entry referred to by Index2 

You return less than 0 if the entry referred to by Index1 is less than the entry referred to by Index2 

You return a number above 0 if the entry referred to by Index1 is greater than the entry referred to by Index2

Note: One of the principle advantages of the CustomSort method is that a TWideStringList may be sorted according to the objects optionally attachable to each string.
 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!