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.

1 | 2 | 4 | 5 | 7 | 7 | 8 |

0 | 1 | 3 | 4 | 6 | 7 | |

2 | 5 |

Array B contains the final sorted array.

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