Proposal #2659: Add sortOn and friends to Data.List

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Tue Oct 7 17:04:30 EDT 2008


On Tue, 2008-10-07 at 11:44 +0200, apfelmus wrote:

> I think that
> 
>   sortBy (comparing f)
> 
> is a very good and modular name for the functionality intended, no need
> to create another one. The only advantage of a special  sortOn  function
> would be that you can document it, i.e. there's no haddock blurb for
> sortBy (comparing f) .

Lets fix the sortBy documentation to mention the comparing idiom.

> Hm, though  sortOn  could be useful if it caches the values of  f  by
> default, like the  sortOn'  proposed. But Jean-Philippe's code is a
> beautiful solution for this situation.
> 
> 
> +1 concerning Down,
> 
> but I don't like the name. In particular I don't like the "get" prefix
> in "getDown". I'd simply use

Can't we do it with just some compare flip function:

sortBy (thing compare)

or

sortBy (thing $ comparing fieldFoo)

Would that work and what would be a good name?


Duncan



More information about the Libraries mailing list