title: Loop Explanation in Counting Sort
body: <p>Could somebody please explain to me the purpose of the second loop in this implementation of counting sort?:</p>
  
  <pre><code>short c[RADIX_MAX] = {0};
  int i;
  
  for (i = 0; i &lt; LEN_MAX; i++) {
      if (i == len)
          break;
      int ind = a.getElem(i); 
      c[ind]++;
  }
  
  for (i = 1; i &lt; RADIX_MAX; i++) {
      if (i == radix)
          break;
      c[i] += c[i - 1];
  }
  
  for (i = LEN_MAX - 1; i &gt;= 0; i--) {
      int j = i - LEN_MAX + len;      
      if (j &lt; 0)
          break;
      int ind = a.getElem(j);
      short t = ind;
      ind = --c[ind];
      b.setElem(ind, t);
  }
  </code></pre>