The mergeSort function is implemented in terms of a worker function mergeSort'. This function is given a grouped list. This grouped list is a pairwise sorted list of lists created from input using the function group2. If mergeSort' receives an empty list, or a list with a single element (single list inside a list), then it returns it as a result.
If mergeSort' receives a lists of list that contains more than one list, then it calls mergeStep' to pairwise merge adjacent lists to create another list of lists.
This can be shown graphically as follows: