input: Write a function to implement a merge sort algorithm that sorts two large lists A and B. The function should compare the first element of list A with the first element of list B, add the smaller element to the result list, and move the corresponding pointer to the next element. If one list is exhausted, add the remaining elements of the other list to the result. The function should return the sorted result.
  assert merge_sort([3, 6, 8, 10, 11], [2, 5, 7, 12])==[2, 3, 5, 6, 7, 8, 10, 11, 12]
  assert merge_sort([1, 3, 5, 7], [2, 4, 6, 8])==[1, 2, 3, 4, 5, 6, 7, 8]
  assert merge_sort([5, 6, 7], [1, 2, 3, 4])==[1, 2, 3, 4, 5, 6, 7]
  assert merge_sort([], [1, 2, 3])==[1, 2, 3]
  assert merge_sort([1, 2, 3], [])==[1, 2, 3]
output: def merge_sort(A, B):
      result = []
      i, j = 0, 0
      while i < len(A) and j < len(B):
          if A[i] < B[j]:
              result.append(A[i])
              i += 1
          else:
              result.append(B[j])
              j += 1
      result.extend(A[i:])
      result.extend(B[j:])
      return result