heap build and sort