
|
TTeeSortCompare
type TTeeSortCompare = function(a, b: Integer): Integer of object;
Unit
TeeProcs
Description
The TeeSort global method sorts custom data in a generic way using the standard QuickSort algorithm.
The Compare function should return -1 if the "a" element is "lower" than the "b" element, 0 is they are equal and 1 if "b" is "lower" than "a".
Example:
In this example, the "TElement" class refers to any class you may have.
procedure TExample.Swap(a,b:Integer);
var tmp : TElement;
begin
tmp:=Element[a];
Element[a]:=Element[b];
Element[b]:=tmp;
end;
Function TExample.Compare(a,b:Integer):Integer;
begin
if Element[a] < Element[b] then result:= -1
else
if Element[b] < Element[a] then result:= 1
else
result:=0
end;
procedure TExample.Sort;
begin
TeeSort(0,Count-1,Compare,Swap);
end;
Send us Help Feedback. Copyright 1995-2024 © by Steema Software. All Rights Reserved.