title: Assist with implementing Radix Sort in JavaScript
body: <p>I need some help implementing the Radix sort algorthim in JavaScript.</p>
  
  <p>I found <a href="http://www.coedu.usf.edu/wwwprog/sort_demo.html" rel="nofollow">this example</a> online, with the following code, but I don't understand how I call the function since it appears to be tailored for that site:</p>
  
  <pre><code>// Radix sort a (base 2)
  // Numbers must be in the range 0 to 2**31 - 1
  function radixSort() {
    readArray('i');
    var b0 = new obj();  // Bin for 0 digits
    var b1 = new obj();  // Bin for 1 digits
  
    for (var i=0; i&lt;32; ++i) {
      if (form.step.checked) {  // Single step
        writeArray('i','a');
  
        if (!confirm("Sort on bit "+i))
          return;    
      }
  
      var mask = 1&lt;&lt;i;     // Digit (2**i)
      var biggest = 2&lt;&lt;i;  // If all of a is smaller, we're done
      var zeros=0;         // Number of elements in b0, b1
      var ones=0;
      var found=false;     // Any digits past i?
  
      for (var j=0; j&lt;n; ++j) { // Sort into bins b0, b1
        if ((a[j] &amp; mask) == 0)
          b0[zeros++] = a[j];
        else
          b1[ones++] = a[j];
  
        if (a[j]&gt;=biggest)  // Any more digits to sort on?
          found=true;
      }
  
      for (j=0; j&lt;zeros; ++j)  // Concatenate b0, b1 back to a
        a[j]=b0[j];
  
      for (j=0; j&lt;ones; ++j)
        a[j+zeros]=b1[j];
  
      form.imoves.value = parseInt(form.imoves.value)+n;
  
      if (!found)
        break;
    }
  
    writeArray('i','a');
  }
  </code></pre>