title: Prolog insertion sort
body: <p>There is a simple Prolog insertion sort alghoritm:</p>
  
  <pre><code>sorting([A|B], Sorted) :- sorting(B, SortedTail), insert(A, SortedTail, Sorted).
  sorting([], []).
  
  insert(A, [B|C], [B|D]) :- A @&gt; B, !, insert(A, C, D).
  insert(A, C, [A|C]).
  </code></pre>
  
  <p>It does well on normal lists:</p>
  
  <pre><code>?- sorting([5, 4, 9, 1, 3, 8], X).
  X = [1, 3, 4, 5, 8, 9].
  </code></pre>
  
  <p>But I also need to sort sublist of list contains any of them:</p>
  
  <pre><code>?- sorting([2, 5, [5, 4, 3], [6, 3], 4, 8], X).
  X = [2, 4, 5, 8, [5, 4, 3], [6, 3]].
  </code></pre>
  
  <p>Is what return now. And</p>
  
  <pre><code>?- sorting([2, 5, [5, 4, 3], [6, 3], 4, 8], X).
  X = [2, 4, 5, 8, [3, 4, 5], [3, 6]].
  </code></pre>
  
  <p>what I need to return. So how can I sort sublist too? Thanks in advance!</p>