Skip to content

sortBy not stable

The library report requires that sortBy be stable.  In
5.04.1 it isn't:

  gunter.philco.com[1995]$ ghci
     ___         ___ _
    / _ \ /\  /\/ __(_)
   / /_\// /_/ / /  | |      GHC Interactive, version
5.04, for Haskell 98.
  / /_\\/ __  / /___| |      http://www.haskell.org/ghc/
  \____/\/ /_/\____/|_|      Type :? for help.
  
  Loading package base ... linking ... done.
  Loading package haskell98 ... linking ... done.
  Prelude> List.sortBy (\ (_,a) (_,b) -> compare a b) $
zip [0..] [100,0,0,0]
  [(3,0),(2,0),(1,0),(0,100)]

.  In 5.02.3, it was stable:

  c966553-A[2314]$ ghci
     ___         ___ _
    / _ \ /\  /\/ __(_)
   / /_\// /_/ / /  | |      GHC Interactive, version
5.02.3, for Haskell 98.
  / /_\\/ __  / /___| |      http://www.haskell.org/ghc/
  \____/\/ /_/\____/|_|      Type :? for help.
  
  Loading package std ... linking ... done.
  Prelude> List.sortBy (\ (_,a) (_,b) -> compare a b) $
zip [0..] [100,0,0,0]
  [(1,0),(2,0),(3,0),(0,100)]
Trac metadata
Trac field Value
Version 5.04.1
Type Bug
TypeOfFailure OtherFailure
Priority high
Resolution ResolvedFixed
Component Prelude
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information