pyufunc.algo_heap_sort#

pyufunc.algo_heap_sort(array, verbose=False)#

Sort the input array using heap sort algorithm.

Parameters:
  • array (Iterable) – iterable object to be sorted.

  • verbose (bool, optional) – Whether to print out running time. Defaults to False.

Raises:

ValueError – Input should be iterable.

Returns:

sorted array

Return type:

Iterable

Example

>>> from pyufunc import heap_sort
>>> heap_sort([3, 6, 8, 10, 1, 2, 1])
[1, 1, 2, 3, 6, 8, 10]
>>> heap_sort([3, 6, 8, 10, 1, 2, 1], verbose=True)
Running time of heap_sort: O(n log n): 29.0
[1, 1, 2, 3, 6, 8, 10]