On Sun, 21 Feb 2010, Leon Smith wrote:

On Sat, Feb 20, 2010 at 5:47 AM, Andrew Coppin
<andrewcop...@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
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to