```python
def counting_sort(my_list):
    """
    Sorts a list of non-negative integers using the counting sort algorithm.
    """
    # If the list has 0 or 1 elements, it is already sorted.
    if len(my_list) < 2:
        return my_list

    # Find the maximum value in the list to determine the range.
    max_val = max(my_list)
    
    # Create a count array to store the frequency of each element.
    count = [0] * (max_val + 1)

    # Populate the count array with the frequency of each number.
    for number in my_list:
        count[number] += 1

    # Modify the count array to store the cumulative sum of counts.
    # This will determine the position of each element in the sorted output.
    for i in range(1, len(count)):
        count[i] += count[i-1]

    # Create a result array to store the sorted elements.
    result = [0] * len(my_list)

    # Build the result array by iterating through the input list in reverse.
    # Iterating in reverse ensures that the sort is stable.
    for number in reversed(my_list):
        # The position in the result array is one less than the cumulative count.
        position = count[number] - 1
        result[position] = number
        # Decrement the count for the placed element.
        count[number] -= 1
    
    # Copy the sorted elements from the result array back to the original list.
    my_list[:] = result
    
    return my_list
```