Skip to the content.
26 February 2024
## Counting sort Here is a simplified explanation of the counting sort algorithm. - Find the maximum number in your input array. - Create a new array of size `max + 1` called `counts` and initialize all elements to zero. - Iterate through the input array and record how many times each number appears. - Accumulate the counts by adding the value of each index to the previous ones. - Iterate through the original array from the end, look up the correct position in the accumulated array, and place the value into the final output array.
Count Sort algorithm diagram
Counting sort algorithm
### JavaScript solution
Count Sort algorithm diagram
Counting sort algorithm