title: Applying custom ordering to lists (to sort a list of lists)
body: <p>There's an example of how to sort a list with a custom ordering at this page:
  <a href="http://zvon.org/other/haskell/Outputlist/sortBy_f.html" rel="nofollow noreferrer">http://zvon.org/other/haskell/Outputlist/sortBy_f.html</a></p>
  
  <pre><code>xxx a b  | odd a = LT
           | otherwise = GT
  
  Input: sortBy xxx [1,2,3,4,5,6,7] 
  
  Output: [1,3,5,7,6,4,2]
  </code></pre>
  
  <p>The standard less than order lets me compare lists, e.g.</p>
  
  <pre><code>[1,2,3] &lt; [0,4,5]
  </code></pre>
  
  <p>Is False. But this doesn't work with the above example function:</p>
  
  <pre><code>Main&gt; xxx [1,2,6] [1,7,3]
  ERROR - Cannot infer instance
  *** Instance   : Integral [a]
  *** Expression : xxx [1,2,6] [1,7,3]
  </code></pre>
  
  <p>Is there an easy way to extend such an order to lists?</p>
  
  <p>The reason I want this functionality is to use sortBy to sort lists of lists using my custom ordering.</p>
  
  <p>I'd be grateful for example solution code, advice on what to read up on, or anything in between. I'm hoping there's some built-in way to do this with the language rather than write a function that compares the lists directly.</p>