Implementation of the merge sort algorithm in O(n log n) running time