Just sort the way you want.
# import the required sort
from pygorithm.sorting import bubble_sort
myList = [12, 4, 2, 14, 3, 7, 5]
# to sort the list
sorted_list = bubble_sort.sort(myList)- Sorts available:
- Bubble Sort (bubble_sort)
- Selection Sort (selection_sort)
- Insertion Sort (insertion_sort)
- Merge Sort (merge_sort)
- Quick Sort (quick_sort)
- Bucket Sort (bucket_sort)
- Counting Sort (counting_sort)
- Heap Sort (heap_sort)
- Shell Sort (shell_sort)
- For sorting:
Remember
sort()function takes its parameter as a list only.
# import the required sort
from pygorithm.sorting import bubble_sort
myList = [12, 4, 2, 14, 3, 7, 5]
# to sort the list
sorted_list = bubble_sort.sort(myList)- Get time complexities of all the sorting algorithms
from pygorithm.sorting import bubble_sort
# for printing time complexities of bubble_sort
print(bubble_sort.time_complexities())- Get the code used for any of the algorithm
from pygorithm.sorting import bubble_sort
# for printing the source code of bubble_sort
print(bubble_sort.get_code())