input: Write a python function to sort an array using merge sort.
  assert sort([4, 2, 9, 7, 3]) == [2, 3, 4, 7, 9]
  assert sort([10, 5, 3, 8, 2, 6, 7, 4, 1, 9]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  assert sort([]) == []
  assert sort([1]) == [1]
  assert sort([5, 3, 8, 6, 2, 7, 4, 1]) == [1, 2, 3, 4, 5, 6, 7, 8]
output: def sort(arr):
      if len(arr) <= 1:
          return arr
      
      mid = len(arr) // 2
      left = sort(arr[:mid])
      right = sort(arr[mid:])
      
      return merge(left, right)
  
  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