advanced sorting listing merging two ordered virtual sublists merges the two sorted virtual subsequences[left right[right endusing the tmparray for intermediate storage def mergevirtualseqtheseqleftrightendtmparray )initialize two subsequence index variables left right initialize an index variable for the resulting merged array merge the two sequences together until one is empty while right and end if theseq[atheseq[btmparray[mtheseq[aa + else tmparray[mtheseq[bb + + if the left subsequence contains more items append them to tmparray while right tmparray[mtheseq[aa + + or if right subsequence contains moreappend them to tmparray while end tmparray[mtheseq[bb + + copy the sorted subsequence back into the original sequence structure for in rangeend left theseq[ +lefttmparray[ithis overheadimplementations of the the merge sort algorithm typically allocate single array that is of the same size as the original list and then simply pass the array into the mergevirtualseq(function the use of the temporary array is illustrated in figure with the merging of the two subsequences lists formed from the second half of the original sequence the implementation of the earlier sorting algorithms only required the user to supply the array or list to be sorted the recmergesort(functionhowevernote wrapper functions wrapper function is function that provides simpler and cleaner interface for another function and typically provides little or no additional functionality wrapper functions are commonly used with recursive functions that require additional arguments since their initial invocation may not be as natural as an equivalent sequential function