void mergeSort (apvector &list, int first, int last) // Recursively divides a list in half, over and over. When the // sublist has one or two values, stop subdividing. { if (first-last==1) // do nothing else if(first-last==2) { if (list[first]>list[last]) swap (list[first],list[last]); } else { last=last/2;; // recursion, divide list into two halves // Find midpoint of current sublist mergeSort(list,first,last); //Call mergeSort and process left sublist mergeSort(list,first,last); //Call mergeSort and process right sublist merge(list,first,last); // merge left and right sublists } }