CLI tool for visualizing sorting algorithms.
-
Have Python 3.6+ installed
-
Open terminal in project's main directory
-
Run
python sort.py
command, optionally add arguments -
Maximize terminal to full screen on windows for smoother effect
python sort.py -h
for list of algorithms and argument help
# | Argument | Type | Default | Description | Required |
---|---|---|---|---|---|
1. | algorithm | str | bubble | sorting algorithm from algorithms folder | ❎ No |
2. | array_size | int | 15 | array with integers ranging from 1 to array_size + 1 | ❎ No |
python sort.py insertion 20
sorts array of numbers in range(1, 21) using insertion sort
-
-
Bubble
-
Insertion
-
-
- Bogosort 💩
Create .py file in algorithms folder, for example myalgorithm.py
File name cannot start with an underscore | |
---|---|
Your function must be named after your file |
# ./sorting-visualizer/algorithms/myalgorithm.py
def myalgorithm(array):
arr_copy = list(array)
while not_sorted:
# modify arr_copy
yield arr_copy # function must yield updated array
# whenever you want to see the change
python sort.py myalgorithm