In summary, the algorithm loops over the items in the first loop, computing a histogram of the number of times each key occurs within the input collection. After that in the second loop, it performs a prefix sum computation on count in order to determine, for each key, the position range where the items having that key should be placed; i.e. items of key should be placed starting in position count[]. Finally, in the third loop, it loops over the items of input again, but in reverse order, moving each item into its sorted position in the output array.
In summary the algorithm loops over the items in the first loop computing a histogram of the number of times each key occurs within the input collection After that in the second loop it performs a prefix sum computation on count in order to determine for each key the position range where the items having that key should be placed; ie items of key should be placed starting in position count[] Finally in the third loop it loops over the items of input again but in reverse order moving each item into its sorted position in the output array