| 1 | Initialize count array with zeros | [0, 0, 0, 0, 0, 0, 0, 0, 0] | [] | [4, 2, 2, 8, 3, 3, 1] | Count array size 9 (0 to 8) |
| 2 | Count occurrences of 4 | [0, 0, 0, 0, 1, 0, 0, 0, 0] | [] | [4, 2, 2, 8, 3, 3, 1] | Increment count[4] |
| 3 | Count occurrences of 2 | [0, 0, 2, 0, 1, 0, 0, 0, 0] | [] | [4, 2, 2, 8, 3, 3, 1] | Increment count[2] twice |
| 4 | Count occurrences of 8 | [0, 0, 2, 0, 1, 0, 0, 0, 1] | [] | [4, 2, 2, 8, 3, 3, 1] | Increment count[8] |
| 5 | Count occurrences of 3 | [0, 0, 2, 2, 1, 0, 0, 0, 1] | [] | [4, 2, 2, 8, 3, 3, 1] | Increment count[3] twice |
| 6 | Count occurrences of 1 | [0, 1, 2, 2, 1, 0, 0, 0, 1] | [] | [4, 2, 2, 8, 3, 3, 1] | Increment count[1] |
| 7 | Modify count array to cumulative counts | [0, 1, 3, 5, 6, 6, 6, 6, 7] | [] | [4, 2, 2, 8, 3, 3, 1] | Each count[i] = count[i] + count[i-1] |
| 8 | Place 1 in output | [0, 0, 3, 5, 6, 6, 6, 6, 7] | [1, _, _, _, _, _, _] | [4, 2, 2, 8, 3, 3, 1] | Place at index count[1]-1=0, decrement count[1] |
| 9 | Place 3 in output | [0, 0, 3, 4, 6, 6, 6, 6, 7] | [1, _, _, _, 3, _, _] | [4, 2, 2, 8, 3, 3, 1] | Place at index count[3]-1=4, decrement count[3] |
| 10 | Place 3 in output | [0, 0, 3, 3, 6, 6, 6, 6, 7] | [1, _, _, 3, 3, _, _] | [4, 2, 2, 8, 3, 3, 1] | Place at index count[3]-1=3, decrement count[3] |
| 11 | Place 8 in output | [0, 0, 3, 3, 6, 6, 6, 6, 6] | [1, _, _, 3, 3, _, 8] | [4, 2, 2, 8, 3, 3, 1] | Place at index count[8]-1=6, decrement count[8] |
| 12 | Place 2 in output | [0, 0, 2, 3, 6, 6, 6, 6, 6] | [1, _, 2, 3, 3, _, 8] | [4, 2, 2, 8, 3, 3, 1] | Place at index count[2]-1=2, decrement count[2] |
| 13 | Place 2 in output | [0, 0, 1, 3, 6, 6, 6, 6, 6] | [1, 2, 2, 3, 3, _, 8] | [4, 2, 2, 8, 3, 3, 1] | Place at index count[2]-1=1, decrement count[2] |
| 14 | Place 4 in output | [0, 0, 1, 3, 5, 6, 6, 6, 6] | [1, 2, 2, 3, 3, 4, 8] | [4, 2, 2, 8, 3, 3, 1] | Place at index count[4]-1=5, decrement count[4] |
| 15 | Copy output array to input array | [0, 0, 1, 3, 5, 6, 6, 6, 6] | [1, 2, 2, 3, 3, 4, 8] | [1, 2, 2, 3, 3, 4, 8] | Input array sorted |
| 16 | End | [0, 0, 1, 3, 5, 6, 6, 6, 6] | [1, 2, 2, 3, 3, 4, 8] | [1, 2, 2, 3, 3, 4, 8] | Sorting complete |