Opened 11 years ago

Closed 11 years ago

Last modified 44 years ago

#97 closed bug (Fixed)

sortBy not stable

Reported by: magunter Owned by: nobody
Priority: high Milestone:
Component: Prelude Version: 5.04.1
Keywords: Cc:
Operating System: Architecture:
Type of failure: Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

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)]

Change History (2)

comment:1 Changed 11 years ago by simonmar

Logged In: YES 
user_id=48280

This one has been fixed, grab 5.04.2 when it is released.

comment:2 Changed 11 years ago by sigbjorn

  • Status changed from assigned to closed
Logged In: YES 
user_id=232905

ghc-5.04.1 does include a stable sort. The bug reporter 
incorrectly refers to ghc-5.04 as ghc-5.04.1
Note: See TracTickets for help on using tickets.