Counting Sort is an sorting algorithm, which sorts the integers( or Objects) given in a specific range.

Algorithm: Time Complexity O(n)

Take two arrays, Count[] and Result[] and given array is input[].

Count[] will store the counts of each integer in the given array.

Update the Count[] so that each index will store the sum till previous step. (Count[i]=Count[i] + Count[i-1]). Now updated Count[] array will reflect the actual position of each integer in Result[].

Now navigate the input array taking one element at a time, Count[input[i]] will tell you the index position of input[i] in Result[]. When you do that, decrease the count in Count[input[i]] by 1. See Example

If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.
__________________________________________________