input: Write a function to optimize the sorting of a list of numbers to achieve an O(n) time complexity. The function should take an unsorted list as input and return the sorted list.
  
  def sort_list(unsorted_list):
      count = [0] * (max(unsorted_list) + 1)
      for num in unsorted_list:
          count[num] += 1
      sorted_list = []
      for i in range(len(count)):
          sorted_list.extend([i] * count[i])
      return sorted_list
  
  assert sort_list([2, 6, 3, 8, 4]) == [2, 3, 4, 6, 8]
  assert sort_list([5, 1, 3, 5, 2]) == [1, 2, 3, 5, 5]
  assert sort_list([10, 2, 3, 2, 1]) == [1, 2, 2, 3, 10]
  assert sort_list([6, 6, 6, 6, 6]) == [6, 6, 6, 6, 6]
  assert sort_list([]) == []
output: def sort_list(unsorted_list):
      if not unsorted_list:
          return []
      count = [0] * (max(unsorted_list) + 1)
      for num in unsorted_list:
          count[num] += 1
      sorted_list = []
      for i in range(len(count)):
          sorted_list.extend([i] * count[i])
      return sorted_list