input: Write a function to optimize the sorting of a given list of numbers (unsorted_list) to achieve O(n) time complexity. If the input list is empty, return an empty list.
  def sort_list(unsorted_list):
      if not unsorted_list:
          return []
      max_val = max(unsorted_list)
      output = [0] * (max_val + 1)
      for num in unsorted_list:
          output[num] += 1
      sorted_list = []
      for i in range(max_val + 1):
          if output[i] > 0:
              sorted_list.extend([i] * output[i])
      return sorted_list
  assert sort_list([2, 6, 3, 8, 4]) == [2, 3, 4, 6, 8]
  assert sort_list([]) == []
  assert sort_list([5, 1, 5, 1, 5]) == [1, 1, 5, 5, 5]
  assert sort_list([4, 4, 4, 4]) == [4, 4, 4, 4]
  assert sort_list([0, 0, 1, 0]) == [0, 0, 0, 1]
output: def sort_list(unsorted_list):
      if not unsorted_list:
          return []
      max_val = max(unsorted_list)
      output = [0] * (max_val + 1)
      for num in unsorted_list:
          output[num] += 1
      sorted_list = []
      for i in range(max_val + 1):
          if output[i] > 0:
              sorted_list.extend([i] * output[i])
      return sorted_list