ghc-5.04 sort not stable?

Jon Fairbairn Jon.Fairbairn at cl.cam.ac.uk
Sat Jul 20 11:42:25 EDT 2002


The library report says

   sort/sortBy implement a stable sorting algorithm

In ghc 5.02.3

List.sortBy (\(a,b) (a',b')->compare a a') ([1,1,1,1,1,1,1,1,1,1]`zip`[1..10])

gives [(1,1),(1,2),(1,3),(1,4),(1,5),(1,6),(1,7),(1,8),(1,9),(1,10)]

but in 5.04

gives [(1,10),(1,9),(1,8),(1,7),(1,6),(1,5),(1,4),(1,3),(1,2),(1,1)]



  Jón

-- 
Jón Fairbairn                                 Jon.Fairbairn at cl.cam.ac.uk
31 Chalmers Road                                         jf at cl.cam.ac.uk
Cambridge CB1 3SZ            +44 1223 570179 (after 14:00 only, please!)





More information about the Glasgow-haskell-bugs mailing list