input: Write a python function to sort an array using the counting sort algorithm.
  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]
output: def counting_sort(arr):
      if not arr:
          return []
      
      max_val = max(arr)
      min_val = min(arr)
      range_of_elements = max_val - min_val + 1
      
      count_arr = [0] * range_of_elements
      output_arr = [0] * len(arr)
      
      for num in arr:
          count_arr[num - min_val] += 1
      
      for i in range(1, len(count_arr)):
          count_arr[i] += count_arr[i - 1]
      
      for num in reversed(arr):
          output_arr[count_arr[num - min_val] - 1] = num
          count_arr[num - min_val] -= 1
      
      return output_arr