input: Write a function to implement an algorithm that merges two sorted lists, A and B, into one sorted list. The function should compare the elements of A and B starting from the beginning, appending the smaller element to the result list and moving the pointer to the next element in the corresponding list. If one list is exhausted, the remaining elements of the other list should be appended to the result list.
  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], [2, 4, 6]) == [1, 2, 3, 4, 5, 6]
  assert merge_sort([], [1, 2, 3]) == [1, 2, 3]
  assert merge_sort([1, 2, 3], []) == [1, 2, 3]
  assert merge_sort([], []) == []
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