[Haskell-cafe] ordering of structured values
paolo.veronelli at gmail.com
Fri Aug 19 16:16:14 UTC 2016
That was easy, thank you !
2016-08-19 17:54 GMT+02:00 Tom Ellis <
tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk>:
> On Fri, Aug 19, 2016 at 05:49:30PM +0200, Paolino wrote:
> > An example on sorting (Ord a, Ord b, Ord c) => [(a,(b,c)] with 'a' in
> > opposite order, then 'c' and 'b' in ascending order goes like
> > sortBy (comparings [Descending fst, Ascending $ snd . snd, Ascending $
> > . snd])
> The answer is: Yes! Haskell can do that:
> sortBy (flip (comparing fst)
> <> comparing (snd . snd)
> <> comparing (fst . snd))
> :: (Ord a, Ord b, Ord a1) => [(a, (a1, b))] -> [(a, (a1, b))]
> Haskell-Cafe mailing list
> To (un)subscribe, modify options or view archives go to:
> Only members subscribed via the mailman list are allowed to post.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe