Implemented the 'merge' procedure for the merge sort