
16 Oct
2009
16 Oct
'09
4:42 a.m.
On Fri, Oct 16, 2009 at 10:37 AM, Chaddaï Fouché
On Fri, Oct 16, 2009 at 8:07 AM, Daniel Fischer
wrote: You would achieve that by
tuplesort = sortBy (comparing fst)
or, eta-expanded,
tuplesort xs = sortBy (comparing fst) xs
But if you finally want to sort by the second component also (subordinate to sorting by the first component), it's much easier to go the whole way at once and use plain "sort".
tuplesort = sortBy (comparing fst `mplus` comparing snd)
Ooops, that's "mappend" rather than "mplus" :
tuplesort = sortBy (comparing fst `mappend` comparing snd)
(it would be really cool if (++) was a synonym for mappend though as it used to be) -- Jedaï