title: Ocaml - Smalltofront in Selection sort
body: <p>Basically I think I have done everything correct for the swap and selectionsort function, but my <em>smalltofront</em> function is the one that's incorrect.</p>
  
  <p>The problem is that I can't figure out how this should be (please see the whole code beneath):</p>
  
  <pre><code> else (if a.(k) &lt; a.(s)
      then smalltofront (a,s,i+1,j,k)
      else smalltofront (a,s,i+1,j,k));;
  </code></pre>
  
  <ul>
  <li>a = array</li>
  <li>s = start of the unsorted subarray</li>
  <li>i = the moving index from left to right</li>
  <li>j = the right most index</li>
  <li>k = is the current index to the smallest entry</li>
  </ul>
  
  <p>What have I done wrong?</p>
  
  <pre><code>let swap (a,i,j) =
  let temp = a.(i)
  in (a.(i)&lt;-a.(j);
  a.(j)&lt;-temp);;
  
  
  
  let rec smalltofront (a,s,i,j,k) =
  if i&gt;j
  then swap (a,s,k)
  else (if a.(k) &lt; a.(s)
  then smalltofront (a,s,i+1,j,k)
  else smalltofront (a,s,i+1,j,k));;
  
  
  let rec selectionsort (a,i,j) = 
  if i&gt;j
  then ()
  else smalltofront (a,i,i,j,i); selectionsort (a,i+1,j);;
  </code></pre>