title: Sort a list in haskell according to a predicate
body: <p>I am trying to learn Haskell and I've come into issues trying to complete an example problem. The problem is to sort a list in Haskell according to a given predicate i.e. the type is </p>
  
  <pre><code>sort :: (a -&gt; a -&gt; Bool) -&gt; [a] -&gt; [a]
  </code></pre>
  
  <p>The code I have so far is :</p>
  
  <pre><code>sort _ [] = []
  sort f (x:xs) =
              let 
              smaller = sort f (filter (f x) xs)
              bigger = sort f (filter (f x) xs) --error is on this line 
              in smaller ++ [x] ++ bigger
  </code></pre>
  
  <p>The code not working correctly in the sense im not sure how to take the opposite of the function. for example if it were an ordinary sort function I would use <code>smaller = quicksort (filter (&lt;=x) xs)</code> and <code>bigger = quicksort (filter (&gt;x) xs)</code> this would then break up the list according to that predicate but how do I do this with a higher order predicate?</p>