input: Write a function to implement merge sort for a list of integers.
  assert merge_sort([4, 2, 3, 6, 1]) == [1, 2, 3, 4, 6]
  assert merge_sort([10, 5, 3, 7, 2, 8, 6, 9, 1, 4]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  assert merge_sort([1, 2, 3, 4, 5]) == [1, 2, 3, 4, 5]
output: def merge_sort(lst):
      if len(lst) <= 1:
          return lst
  
      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(lst) // 2
      left = merge_sort(lst[:mid])
      right = merge_sort(lst[mid:])
      return merge(left, right)