[Haskell-cafe] A small oversight

Henning Thielemann lemming at henning-thielemann.de
Mon Feb 22 13:53:06 EST 2010


On Sun, 21 Feb 2010, Leon Smith wrote:

> On Sat, Feb 20, 2010 at 5:47 AM, Andrew Coppin
> <andrewcoppin at btinternet.com> wrote:
>
>>  sortOn :: (Ord y) => (x -> y) -> [x] -> [x]
>>  sortOn foo = sortBy (compare `on` foo)
>
>
> Incidentally,  this function is provided as Data.List.Ordered.sortOn'
> in the data-ordlist package...

Or Key.sort in utility-ht which caches the keys to be sorted.
Useful if the function is not just a record selector.
http://hackage.haskell.org/packages/archive/utility-ht/0.0.5.1/doc/html/Data-List-Key.html#v%3Asort


More information about the Haskell-Cafe mailing list