title: Javascript insertion sort bug
body: <p>I've been trying to convert my python code into javascript. Basically it's a insertion sort that also sorts a secondary list of the same size with arbitrary values relative to the first list.</p>
  
  <p>i.e. a = [3,2,1] and b = [c,b,a] will return [1,2,3] and [a,b,c] for a and b.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>function insertionSort(alist,bList){
      for (index=1;index&lt;alist.length;index++){
          var currentvalue = alist[index]
          var currentvalue2 = blist[index]
          var position = index
      }
      while (position&gt;0 &amp;&amp; alist[position-1]&gt;currentvalue){
          alist[position]=alist[position-1]
          blist[position]=blist[position-1]
          position = position-1
      }
      alist[position]=currentvalue
      blist[position]=currentvalue2
  }
  </code></pre>
  
  <p>Works fine in python, but not at all here. What have I done?</p>
  
  <p>Thanks so much.</p>