-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathquick_sort.py
More file actions
51 lines (24 loc) · 687 Bytes
/
Copy pathquick_sort.py
File metadata and controls
51 lines (24 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from OFA import *
def sort(high, low=0, list=blocks):
if low < high:
pi = partition(list, low, high)
sort(pi-1, low, list)
sort(high, pi+1, list)
def partition(list, low, high):
i = low-1
pivot = list[high].h
for j in range(low, high):
if list[j].h < pivot:
i = i+1
swap(i, j, list)
time.sleep(0.04)
swap(i+1, high, list)
return (i+1)
if __name__ == "__main__":
tk.title("Quick Sort")
generate()
btn1 = Button(tk, text = 'Shuffle', bd = '5', command = lambda: shuffle())
btn2 = Button(tk, text = 'Sort', bd = '5', command = lambda: sort(tk, canvas, blocks, SIZE))
btn1.pack(side='left')
btn2.pack(side='left')
tk.mainloop()