anchor.diff:     end else begin
       if (Depth=0) or (ptruint(pointer(StackItem))>=ptruint(pointer(@Stack[high(Stack)-1]))) then begin
        // Heap sort
  -     Size:=(Right-Left)+1;
        i:=Size div 2;
        Temp:=nil;
        repeat
  
positive.code: end;
  {$endif}
  
  procedure DirectIntroSort(Items:pointer;Left,Right,ElementSize:longint;CompareFunc:TSortCompareFunction);
  type PByteArray=^TByteArray;
       TByteArray=array[0..$3fffffff] of byte;
  
negative.code:    Left:=StackItem^.Left;
     Right:=StackItem^.Right;
     Depth:=StackItem^.Depth;
     Size:=(Right-Left)+1;
     if Size<16 then begin
      // Insertion sort
      iA:=Left;
      iB:=iA+1;
      while iB<=Right do begin
       iC:=iB;
       while (iA>=Left) and
             (iC>=Left) and
             (CompareFunc(pointer(@PByteArray(Items)^[iA*ElementSize]),pointer(@PByteArray(Items)^[iC*ElementSize]))>0) do begin
        MemorySwap(@PByteArray(Items)^[iA*ElementSize],@PByteArray(Items)^[iC*ElementSize],ElementSize);
        dec(iA);
        dec(iC);
       end;
       iA:=iB;
       inc(iB);
      end;
     end else begin
      if (Depth=0) or (ptruint(pointer(StackItem))>=ptruint(pointer(@Stack[high(Stack)-1]))) then begin
       // Heap sort
       i:=Size div 2;
       repeat
        if i>0 then begin
         dec(i);
        end else begin
         dec(Size);
         if Size>0 then begin
          MemorySwap(@PByteArray(Items)^[(Left+Size)*ElementSize],@PByteArray(Items)^[Left*ElementSize],ElementSize);
         end else begin
          break;
         end;
        end;
        Parent:=i;
        repeat
         Child:=(Parent*2)+1;
         if Child<Size then begin
          if (Child<(Size-1)) and (CompareFunc(pointer(@PByteArray(Items)^[(Left+Child)*ElementSize]),pointer(@PByteArray(Items)^[(Left+Child+1)*ElementSize]))<0) then begin
           inc(Child);
          end;
          if CompareFunc(pointer(@PByteArray(Items)^[(Left+Parent)*ElementSize]),pointer(@PByteArray(Items)^[(Left+Child)*ElementSize]))<0 then begin
           MemorySwap(@PByteArray(Items)^[(Left+Parent)*ElementSize],@PByteArray(Items)^[(Left+Child)*ElementSize],ElementSize);
           Parent:=Child;
           continue;
          end;
         end;
         break;
        until false;
       until false;
      end else begin
       // Quick sort width median-of-three optimization
       Middle:=Left+((Right-Left) shr 1);
       if (Right-Left)>3 then begin
        if CompareFunc(pointer(@PByteArray(Items)^[Left*ElementSize]),pointer(@PByteArray(Items)^[Middle*ElementSize]))>0 then begin
         MemorySwap(@PByteArray(Items)^[Left*ElementSize],@PByteArray(Items)^[Middle*ElementSize],ElementSize);
        end;
        if CompareFunc(pointer(@PByteArray(Items)^[Left*ElementSize]),pointer(@PByteArray(Items)^[Right*ElementSize]))>0 then begin
         MemorySwap(@PByteArray(Items)^[Left*ElementSize],@PByteArray(Items)^[Right*ElementSize],ElementSize);
        end;
        if CompareFunc(pointer(@PByteArray(Items)^[Middle*ElementSize]),pointer(@PByteArray(Items)^[Right*ElementSize]))>0 then begin
         MemorySwap(@PByteArray(Items)^[Middle*ElementSize],@PByteArray(Items)^[Right*ElementSize],ElementSize);
        end;
       end;
       Pivot:=Middle;
       i:=Left;
       j:=Right;
       repeat
        while (i<Right) and (CompareFunc(pointer(@PByteArray(Items)^[i*ElementSize]),pointer(@PByteArray(Items)^[Pivot*ElementSize]))<0) do begin
         inc(i);
        end;
        while (j>=i) and (CompareFunc(pointer(@PByteArray(Items)^[j*ElementSize]),pointer(@PByteArray(Items)^[Pivot*ElementSize]))>0) do begin
         dec(j);
        end;
        if i>j then begin
         break;
        end else begin
         if i<>j then begin
          MemorySwap(@PByteArray(Items)^[i*ElementSize],@PByteArray(Items)^[j*ElementSize],ElementSize);
          if Pivot=i then begin
           Pivot:=j;
          end else if Pivot=j then begin
           Pivot:=i;
          end;
         end;
         inc(i);
         dec(j);
        end;
       until false;
       if i<Right then begin
        StackItem^.Left:=i;
        StackItem^.Right:=Right;
        StackItem^.Depth:=Depth-1;
        inc(StackItem);
       end;
       if Left<j then begin
        StackItem^.Left:=Left;
        StackItem^.Right:=j;
        StackItem^.Depth:=Depth-1;
        inc(StackItem);
       end;
      end;
     end;
    end;
   end;
  end;
  
  procedure IndirectIntroSort(Items:pointer;Left,Right:longint;CompareFunc:TSortCompareFunction);
  type PPointers=^TPointers;
       TPointers=array[0..$ffff] of pointer;
       PStackItem=^TStackItem;
       TStackItem=record
        Left,Right,Depth:longint;
       end;
  var Depth,i,j,Middle,Size,Parent,Child:longint;
      Pivot,Temp:pointer;
      StackItem:PStackItem;
      Stack:array[0..31] of TStackItem;
  begin
   if Left<Right then begin
    StackItem:=@Stack[0];
    StackItem^.Left:=Left;
    StackItem^.Right:=Right;
    StackItem^.Depth:=IntLog2((Right-Left)+1) shl 1;
    inc(StackItem);
    while ptruint(pointer(StackItem))>ptruint(pointer(@Stack[0])) do begin
     dec(StackItem);
     Left:=StackItem^.Left;
     Right:=StackItem^.Right;
     Depth:=StackItem^.Depth;
     Size:=(Right-Left)+1;
     if Size<16 then begin
      // Insertion sort
      for i:=Left+1 to Right do begin
       Temp:=PPointers(Items)^[i];
  