input: Write a function to perform merge sort on a list of numbers.
  assert merge_sort([7, 3, 5, 8, 2, 9, 1, 4])==[1, 2, 3, 4, 5, 7, 8, 9]
  assert merge_sort([10, 3, 15, 7, 8, 23, 74, 18])==[3, 7, 8, 10, 15, 18, 23, 74]
  assert merge_sort([1, 4, 3, 2])==[1, 2, 3, 4]
output: def merge_sort(lst):
      if len(lst) <= 1:
          return lst
  
      def merge(left, right):
          merged_list = []
          left_index, right_index = 0, 0
  
          while left_index < len(left) and right_index < len(right):
              if left[left_index] < right[right_index]:
                  merged_list.append(left[left_index])
                  left_index += 1
              else:
                  merged_list.append(right[right_index])
                  right_index += 1
  
          merged_list.extend(left[left_index:])
          merged_list.extend(right[right_index:])
  
          return merged_list
  
      mid = len(lst) // 2
      left_half = merge_sort(lst[:mid])
      right_half = merge_sort(lst[mid:])
  
      return merge(left_half, right_half)