I was having problems getting the sort to always sort properly. I have another quicksort array algorithm laying about that appears to work more reliably, but requires loosing the const on the l parameter.
procedure TNode<T>.PrivateSort(const ACompare: TCompareProc; l,r:TInteger);
var
I, J: TInteger;
P, T: Pointer;
begin
if r < 0 then
exit;
repeat
I := L;
J := R;
P := fItems[(L + R) shr 1];
repeat
while ACompare(fItems[I], P) < 0 do
Inc(I);
while ACompare(fItems[J], P) > 0 do
Dec(J);
if I <= J then
begin
if I <> J then
begin
Exchange(I,J);
end;
Inc(I);
Dec(J);
end;
until I > J;
if L < J then
privatesort(ACompare,L,J);
L := I;
until I >= R;
end;