TSubstringList.CustomSort Method

procedure CustomSort(const Compare: TSubstringListSortCompare);

Sorts the list by Compare, stably; a sorted list is left as it is.

#NameDescription
1Compare

The order: negative when Item1 sorts before Item2, 0 when they are equal, positive after.

Result: stored in self (calling object)

Examples

Ordering by code unit, upper case first.

uses Substr;

procedure Example;
var List: TSubstringList;
begin
    List := TSubstringList.Create(4);
    try
        List.Add('b');
        List.Add('B');
        List.Add('a');
        List.CustomSort(Substring.Compare);
        Assert(List[0] = 'B');
        Assert(List[1] = 'a');
        Assert(List[2] = 'b');
    finally
        List.Free;
    end;
end;
See Also: TSubstringList.Sort, TSubstringList.Sort, TSubstringListSortCompare