sorting in the heap