[Haskell-beginners] sorting by elements in a tuple
Ryan Temple
ryantemple145 at googlemail.com
Thu Oct 15 19:19:34 EDT 2009
I am wanting to sort a list of tuples by the first and then the second item
in the tuple. So [(1,2),(4,2),(2,5)] would become [(1,2),(2,5),(4,2)] I am
attempting to use the Sorty function but don't seem to be having much luck
tuplesort :: [(a,b)] -> [(a,b)]
tuplesort [(_,_)] = sortBy (comparing fst) -- this is an attempt to
organise by the first element in the tuple
Any help would be much appreciated
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/beginners/attachments/20091015/1ed3244e/attachment.html
More information about the Beginners
mailing list