Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#9337 closed feature request (duplicate)

Add `sortOn` function to Data.List

Reported by: JohnWiegley Owned by:
Priority: normal Milestone: 7.10.1
Component: libraries/base Version: 7.8.3
Keywords: Cc: hvr, ekmett
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #9004, #2659 Differential Rev(s):
Wiki Page:

Description

This passed the vote on the libraries list a while ago, but I forget to add a ticket. The request was to add sortOn to Data.List:

-- | Sort a list using a key on each element.  This implements the
--   decorate-sort-undecorate paradigm, also called a Schwarzian transform.
sortOn :: Ord b => (a -> b) -> [a] -> [a]
sortOn f = map snd . sortBy (comparing fst) . map (\x -> (f x, x))

Change History (8)

comment:1 Changed 5 years ago by ekmett

It is "Schwartzian". ;)

Otherwise, this passed the libraries process easily and folks on the committee who were asked about it were all in favor, so it looks good to me.

comment:2 Changed 5 years ago by JohnWiegley

Ack, my German teacher just rolled in her grave. Thanks for catching that. :)

comment:3 Changed 5 years ago by hvr

I'd like to push this to base, whom shall I declare as being the author?

comment:4 Changed 5 years ago by hvr

wait a minute... why did you resubmit this? wasn't this already handled by #9004?

comment:5 Changed 5 years ago by JohnWiegley

hvr, you're right, this is a duplicate.

comment:6 Changed 5 years ago by hvr

Resolution: duplicate
Status: newclosed

comment:7 Changed 4 years ago by JohnWiegley

This is also a dupe of part of #2659, which was closed 5 years ago now as wontfix.

comment:8 Changed 4 years ago by ekmett

Note: See TracTickets for help on using tickets.