function sort( var r : list; n : integer ) : list;
var temp : list;
begin
if r = nil then sort := nil
else if n>1 then
sort := merge( sort( r, n div 2 ),
sort( r, (n+1) div 2 ))
else begin
temp := r;
r := r^.next;
temp^.next := nil;
sort := temp
end
end;
|