implemented parameterized merge sort function (Lecture 5.3)