code: private void bucketsort(int n, int k) {
          int pi;// pointer
          int i, c, d, g;
  
          for (pi = 0; pi < k; ++pi)
              I[pi] = -1; /* mark linked lists empty. */
          for (i = 0; i <= n; ++i) {
              V[start + i] = I[c = V[start + i]]; /* insert in linked list. */
              I[c] = i;
          }
          for (pi = k - 1, i = n; pi >= 0; --pi) {
              d = V[start + (c = I[pi])]; /* c is position, d is next in list. */
              V[start + c] = g = i; /* last position equals group number. */
              if (d >= 0) { /* if more than one element in group. */
                  I[i--] = c; /* p is permutation for the sorted x. */
                  do {
                      d = V[start + (c = d)]; /* next in linked list. */
                      V[start + c] = g; /* group number in x. */
                      I[i--] = c; /* permutation in p. */
                  }
                  while (d >= 0);
              } else I[i--] = -1; /* one element, sorted group. */
          }
      }
docs: Bucketsort for first iteration.
  <p>
  Input: <code>V[0...n-1]</code> holds integers in the range <code>1...k-1</code>,
  all of which appear at least once. <code>V[n]</code> is <code>0</code>. (This is
  the corresponding output of transform.) <code>k</code> must be at most
  <code>n+1</code>. <code>I</code> is array of size <code>n+1</code> whose contents
  are disregarded.