I am a beginner in Haskell so please bear with me. (Just started learning yesterday!) How can I sort a list of tuples primarily by their first components (highest to smallest) and secondarily by their second components (smallest to highest)? A sample input/output would be:
[(1, "b"), (1, "a"), (2, "b"), (2, "a")]
(input)
[(1, "a"), (2, "a"), (1, "b"), (2, "b")]
(middle step)
[(2, "a"), (2, "b"), (1, "a"), (1, "b")]
(output)
I tried using the following but it gave wrong output:
sortGT a b = GT
sortBy sortGT lst
I am sure that I can do this by using sortBy
only, but I can't figure it out myself. Any help would be highly appreciated!