Download bubbleSort.py from shukdevdatta123/Sorting-Visualization: direct link, hf CLI and curl.
- Browser
- Download file 446 Bytes
-
https://huggingface.co/spaces/shukdevdatta123/Sorting-Visualization/resolve/09678fd63520e9e7ea10140b2d7bbb2f4c0706bd/bubbleSort.py
- Command line
-
hf download hf://spaces/shukdevdatta123/Sorting-Visualization@09678fd63520e9e7ea10140b2d7bbb2f4c0706bd/bubbleSort.py
-
curl -L -o bubbleSort.py https://huggingface.co/spaces/shukdevdatta123/Sorting-Visualization/resolve/09678fd63520e9e7ea10140b2d7bbb2f4c0706bd/bubbleSort.py
446 Bytes
| import time | |
| from colors import * | |
| def bubble_sort(data, draw_data, time_tick): | |
| size = len(data) | |
| for i in range(size-1): | |
| for j in range(size-i-1): | |
| if data[j] > data[j+1]: | |
| data[j], data[j+1] = data[j+1], data[j] | |
| draw_data(data, [YELLOW if x == j or x == j+1 else BLUE for x in range(len(data))]) | |
| time.sleep(time_tick) | |
| draw_data(data, [BLUE for x in range(len(data))]) |