pyufunc.algo_selection_sort#

pyufunc.algo_selection_sort(array, verbose=False)#

Sort the input array using selection sort algorithm.

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

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

Raises:

ValueError – Input should be a sequence.

Returns:

sorted array

Return type:

Iterable

Example

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