countingsort
Counting sort is a non-comparative sorting algorithm designed for integers that fall within a known, bounded range. The core idea is to count how many times each value appears and then use those counts to place elements directly into the correct positions in the output array. A counts array is created with a size equal to the range of input values. Each element in the input increments the count at its value index. If the data range does not start at zero, the values can be shifted by subtracting the minimum value to fit into an indexable range.
To produce a sorted sequence, a second pass converts the frequency counts into starting indices. This is
Counting sort runs in linear time relative to n and the range: time complexity is O(n + k),