iterative_mergesort functional