input: Write a python function to perform merge sort.
  assert merge_sort([8, 4, 14, 1, 9]) == [1, 4, 8, 9, 14]
  assert merge_sort([3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]) == [1, 1, 2, 3, 3, 4, 5, 5, 5, 6, 9]
  assert merge_sort([]) == []
  assert merge_sort([5, 4, 3, 2, 1]) == [1, 2, 3, 4, 5]
output: def merge_sort(arr):
      if len(arr) <= 1:
          return arr
      
      mid = len(arr) // 2
      left_half = merge_sort(arr[:mid])
      right_half = merge_sort(arr[mid:])
      
      return merge(left_half, right_half)
  
  def merge(left, right):
      result = []
      i = j = 0
  
      while i < len(left) and j < len(right):
          if left[i] < right[j]:
              result.append(left[i])
              i += 1
          else:
              result.append(right[j])
              j += 1
  
      result.extend(left[i:])
      result.extend(right[j:])
  
      return result