input: from typing import List
  
  def merge_sort(A: List[int], B: List[int]) -> List[int]:
      """
      This function merges two sorted lists A and B into a single sorted list.
      It does this by comparing the first elements of both lists, appending the smaller element to the result,
      and moving the pointer to the next element in the list from which the smaller element was taken.
      When one list is exhausted, the remaining elements of the other list are appended to the result.
      
      >>> merge_sort([3, 6, 8, 10, 11], [2, 5, 7, 12])
      [2, 3, 5, 6, 7, 8, 10, 11, 12]
      """
output:     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