The heap data structure is an array object than can be viewd as a complete binary tree. Heapsort algorithm mainly utilizes the property of the max-heap or min-heap (the program below introduces the max-heap) to sort the array and costs O(nlg n) ,which is asymptotically optimal comparison sort.
Please refer to Introduction to Algorithms to get more details about the heapsort.