Overload List
| # | Signature | Description |
|---|---|---|
| 1 | procedure Sort; overload; | Sorts the list by its comparison, stably; a sorted list is left as it is. |
| 2 | procedure Sort(const Compare: TSubstringListSortCompare); overload; | Sorts the list by Compare, stably, as CustomSort. |
Overload 1: procedure Sort; overload;
Sorts the list by its comparison, stably; a sorted list is left as it is.
Result: stored in self (calling object)
Remarks:
Only the items' order changes: no text moves, and no memory is taken.
Examples
No text moves: a view of an item still reads it.
uses Substr;
procedure Example;
var List: TSubstringList;
s: Substring;
begin
List := TSubstringList.Create(2);
try
List.Add('b');
List.Add('a');
s := List[0];
List.Sort;
Assert((List[0] = 'a') and (List[1] = 'b'));
Assert(s.Data = List[1].Data);
finally
List.Free;
end;
end;
Overload 2: procedure Sort(const Compare: TSubstringListSortCompare); overload;
Sorts the list by Compare, stably, as CustomSort.
| # | Name | Description |
|---|---|---|
| 1 | Compare | The order: negative when Item1 sorts before Item2, 0 when they are equal, positive after. |
Result: stored in self (calling object)