sort( r, lo, up )
ArrayToSort r;
int lo, up;{int i, j;
ArrayEntry tempr;
for ( i=up-1; i>=lo; i-- ) {
tempr = r[i];
for ( j=i+1; j<=up && (tempr.k>r[j].k); j++ )
r[j-1] = r[j];
r[j-1] = tempr;
}
};
procedure sort( var r : ArrayToSort; lo, up : integer );
var i, j : integer;
tempr : ArrayEntry;
flag : boolean;
begin
for i:=up-1 downto lo do begin
tempr := r[i];
j := i+1;
flag := true;
while (j<=up) and flag do
if tempr.k > r[j].k then begin
r[j-1] := r[j];
j := j+1
end
else flag := false;
r[j-1] := tempr
end
end;