implementation of recursive merge sort