Completed implementation of merge sort algorithm