semi functional heap k-increasing-decreasing array sort