Implements head data type and heapsort.