Implemented k-way merge sort