merge_sort() function so far only separates the input list into many different parts — pretty much the opposite of what you’d expect a merge sort to do. To actually perform the merging, we’re going to define a helper function that joins the data together.
Define the function
merge(), which is going to take care of merging our two lists together. It should take two parameters:
right. These are going to be the two (sorted) lists we want to merge.
Instantiate a new empty list and call it
result. We’re going to add members of
result until it contains a sorted list with all elements of both.
result at the end of the function.