title: composing two comparison functions?
body: <p>I'd like to sort by one property and then by another (if the first property is the same.)</p>
  
  <p>What's the idiomatic way in Haskell of composing two comparison functions, i.e. a function used with <code>sortBy</code>?</p>
  
  <p>Given</p>
  
  <pre><code>f :: Ord a =&gt; a -&gt; a -&gt; Ordering
  g :: Ord a =&gt; a -&gt; a -&gt; Ordering
  </code></pre>
  
  <p>composing <code>f</code> and <code>g</code> would yield:</p>
  
  <pre><code>h x y = case v of
            EQ -&gt; g x y
            otherwise -&gt; v
          where v = f x y
  </code></pre>