procedure sort( var r : ArrayToSort; lo, up : integer );
var i : integer;
tempr : ArrayEntry;
begin
{*** construct heap ***}
for i := (up div 2) downto 2 do siftup(r,i,up);
{*** repeatedly extract maximum ***}
for i := up downto 2 do begin
siftup(r,1,i);
tempr := r[1];
r[1] := r[i];
r[i] := tempr
end
end;
|