input: Write a function to implement a sorting algorithm for two lists A and B. The algorithm should compare the first elements of A and B. If the element from A is greater than the element from B, it should add the element from B to the result list and move the pointer of B to the next element. If the element from A is smaller, it should move the pointer to the next element of A. This process should continue until all elements from both lists are added to the result list. The function should return the sorted list.
  def merge_sort(A, B):
   result = [] 
   i, j = 0, 0
  
  # Compare elements and add lower one to result
  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
  
  # Add remaining elements
  result += A[i:]
  result += B[j:]
  
  return result
  
  #Test the algorithm
  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, 8, 12], [1, 2, 3, 4, 6, 7, 9, 10, 11]) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
  assert merge_sort([], [1, 2, 3]) == [1, 2, 3]
  assert merge_sort([1], []) == [1]
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 += A[i:]
   result += B[j:]
  
   return result