module FastSort where import Gofer {- list sorting: see L.C.Paulson, ML for the working programmer, Cambidge, p100 -- The list is split into ascending chunks which are then merged in pairs. samsort l = sorting [] 0 l where sorting ls k [] = head(mergepairs ls 0) sorting ls k (x:xs) = sorting (mergepairs (run:ls) kinc) kinc tl where (run, tl) = nextrun [x] xs kinc = k+1 nextrun run [] = (reverse run, []) nextrun rs@(r:_) xl@(x:xs) | x