title: Prolog Quicksort using second element as a pivot
body: <p>I've been trying to learn prolog and I want to use the second element of a list as the pivot of a quicksort.</p>
  
  <p>I thought using [Head | [Pivot | Tail] ] as the input in the method would work, but then I was not sure where I could place "Head", the first element.</p>
  
  <p>like this:</p>
  
  <pre><code>qsort([],[]):- !.
  qsort([Head|[Pivot|Tail]],Sorted):-
          split(Pivot,[Head|Tail],Less,Greater),
          qsort(Less,SortedLess),
          qsort(Greater,SortedGreater),
          append(SortedLess,[Pivot|SortedGreater],Sorted).
  split(_,[],[],[]).
  split(Pivot,[X|T],[X|Less],Greater):-
          X=&lt;Pivot,split(Pivot,T,Less,Greater).
  split(Pivot,[X|T],Less,[X|Greater]):-
          X&gt;Pivot,split(Pivot,T,Less,Greater).
  </code></pre>
  
  <p>However, when I try to sort the list with <code>qsort([8, 3, 4, 12, 25, 4, 6, 1, 9, 22, 6], Sorted).</code> It simply returns false. What am I doing wrong?</p>