input: Write a python function to sort a list using merge sort.
  assert merge_sort([4, 3, 2, 1]) == [1, 2, 3, 4]
  assert merge_sort([10, 5, 2, 3]) == [2, 3, 5, 10]
  assert merge_sort([1, 0, 7, 5, 9]) == [0, 1, 5, 7, 9]
output: def merge_sort(arr):
      if len(arr) <= 1:
          return arr
  
      def merge(left, right):
          merged = []
          left_idx, right_idx = 0, 0
          while left_idx < len(left) and right_idx < len(right):
              if left[left_idx] < right[right_idx]:
                  merged.append(left[left_idx])
                  left_idx += 1
              else:
                  merged.append(right[right_idx])
                  right_idx += 1
          merged.extend(left[left_idx:])
          merged.extend(right[right_idx:])
          return merged
  
      mid = len(arr) // 2
      left_half = merge_sort(arr[:mid])
      right_half = merge_sort(arr[mid:])
      return merge(left_half, right_half)