Added heapsort utility function to the lib/ framework.