partially sorted array sort via heap