stack and mergesort