------
## 最终结论
```python
def counting_sort(arr):
    if not arr:
        return arr
    
    max_val = max(arr)
    min_val = min(arr)
    
    range_of_elements = max_val - min_val + 1
    count = [0] * range_of_elements
    output = [0] * len(arr)
    
    for number in arr:
        count[number - min_val] += 1
    
    for i in range(1, len(count)):
        count[i] += count[i - 1]
    
    for number in reversed(arr):
        output[count[number - min_val] - 1] = number
        count[number - min_val] -= 1
    
    return output

# Test cases
assert counting_sort([1, 23, 4, 5, 6, 7, 8]) == [1, 4, 5, 6, 7, 8, 23]
assert counting_sort([12, 9, 28, 33, 69, 45]) == [9, 12, 28, 33, 45, 69]
assert counting_sort([8, 4, 14, 3, 2, 1]) == [1, 2, 3, 4, 8, 14]
```