pyufunc.algo_bubble_sort#
- pyufunc.algo_bubble_sort(array, verbose=False)#
Sort the input array using bubble 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 bubble_sort >>> bubble_sort([3, 6, 8, 10, 1, 2, 1]) [1, 1, 2, 3, 6, 8, 10] >>> bubble_sort([3, 6, 8, 10, 1, 2, 1], verbose=True) Running time of bubble_sort: O(n^2) [1, 1, 2, 3, 6, 8, 10]