#9004: Add sortOn function to Data.List -------------------------------+------------------------------------------- Reporter: | Owner: JohnWiegley | Status: patch Type: feature | Milestone: 7.10.1 request | Version: 7.8.2 Priority: normal | Keywords: Component: | Architecture: Unknown/Multiple libraries/base | Difficulty: Easy (less than 1 hour) Resolution: | Blocked By: Operating System: | Related Tickets: Unknown/Multiple | Type of failure: | None/Unknown | Test Case: | Blocking: | -------------------------------+------------------------------------------- Comment (by Herbert Valerio Riedel <hvr@…>): In [changeset:"44512e3c855d8fb36ab6580f4f97f842ebcf4c6c/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="44512e3c855d8fb36ab6580f4f97f842ebcf4c6c" Add Data.List.sortOn function (re #9004 and #2659) `sortOn` sorts a list by comparing the results of a key function applied to each element. `sortOn f` is equivalent to `sortBy . comparing f`, but has the performance advantage of only evaluating `f` once for each element in the input list. Historical note: This was already proposed in 2008 as part of http://www.haskell.org/pipermail/libraries/2008-October/010797.html It was, however, the recent re-attempt http://www.haskell.org/pipermail/libraries/2014-April/022489.html that let `sortOn` make it into base at last. Maybe the other functions mentioned in #2659 might be worth reconsidering as well. }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9004#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler