Implementation of an in-place heapsort algorithm