In Haskell, how can I use the built in sortBy function to sort a list of pairs(tuple)?
You need to construct your function sortGT, so that it compares pairs the way you want it: sortGT (a1, b1) (a2, b2) | a1 < a2 = GT | a1 > a2 = LT | a1 == a2 = compare b1 b2 Using this you get the following results (I used ghci): *Main Data.List> sortBy … Read more