Let array A be the following array (n=8, k=7).

5 | 7 | 3 | 5 | 2 | 1 | 4 | 3 |

Compute C[j] as the number of elements in A[] j.
Array C is thus the following array.

Click mouse to advance to next frame.

Array B contains the final sorted array.

1 | 2 | 3 | 3 | 4 | 5 | 5 | 7 |