Oscillating sort


procedure sort( n, unit, direction : integer ); var i, r : integer; begin if n=0 then {*** Mark as dummy entry ***} FilStat[unit] := '-' else if n=1 then ReadOneRun( unit, direction ) else for i:=1 to T-2 do begin r := n div (T-i-1); n := n-r; sort( r, (unit+i-2) mod T + 2, -direction ); MergeOneRunInto( unit, -direction ) end end;

Pascal source (445.sort.p)



© Addison-Wesley Publishing Co. Inc.