title: In Haskell, how can I use the built in sortBy function to sort a list of pairs(tuple)?
body: <p>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:</p>
  
  <p><code>[(1, "b"), (1, "a"), (2, "b"), (2, "a")]</code> (input)</p>
  
  <p><code>[(1, "a"), (2, "a"), (1, "b"), (2, "b")]</code> (middle step)</p>
  
  <p><code>[(2, "a"), (2, "b"), (1, "a"), (1, "b")]</code> (output)</p>
  
  <p>I tried using the following but it gave wrong output:</p>
  
  <pre><code>sortGT a b = GT
  
  sortBy sortGT lst
  </code></pre>
  
  <p>I am sure that I can do this by using <a href="http://haskell.org/ghc/docs/latest/html/libraries/base-4.2.0.0/Data-List.html#v:sortBy" rel="noreferrer"><code>sortBy</code></a> only, but I can't figure it out myself. Any help would be highly appreciated!</p>