To merge two sorted lists is to make one sorted list of all their elements, by repeatedly moving the smaller of their two first elements to the output. Merge sort sorts a list by splitting it into two halves, sorting each by merge sort, and merging the results; a list of or element is already sorted.
merge. The grey elements are already in out, which is sorted and holds the smallest of a and of b. Only a[i] and b[j] are compared: the smaller is the next element.