implemented k-way-mergesort