Implementing heap-sort.