input: Write a function to perform merge sort on a list of integers.
  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([5, 3, 8, 4, 2, 7, 1, 10]) == [1, 2, 3, 4, 5, 7, 8, 10]
  assert merge_sort([12, 11, 13, 5, 6, 7]) == [5, 6, 7, 11, 12, 13]
output: def merge_sort(arr):
      if len(arr) <= 1:
          return arr
  
      def merge(left, right):
          sorted_list = []
          while left and right:
              if left[0] <= right[0]:
                  sorted_list.append(left.pop(0))
              else:
                  sorted_list.append(right.pop(0))
          sorted_list.extend(left if left else right)
          return sorted_list
  
      mid = len(arr) // 2
      left_half = merge_sort(arr[:mid])
      right_half = merge_sort(arr[mid:])
      
      return merge(left_half, right_half)