@@ -41,7 +41,7 @@ def drawRect(array, color):
41
41
x1 = (i + 1 ) * x_width + x_left
42
42
y1 = c_height
43
43
canvas .create_rectangle (x0 , y0 , x1 , y1 , fill = color [i ])
44
- canvas .create_text (x0 + 2 , y0 , anchor = SW , text = str (array [i ]))
44
+ canvas .create_text (x0 + 2 , y0 , anchor = SW , text = str (array [i ]))
45
45
46
46
root .update_idletasks ()
47
47
@@ -72,20 +72,20 @@ def partition(array, left, right, drawRect):
72
72
i = left + 1
73
73
pivot = array [left ]
74
74
75
- for j in range (left + 1 , right + 1 ):
75
+ for j in range (left + 1 , right + 1 ):
76
76
if array [j ] < pivot :
77
77
array [i ], array [j ] = array [j ], array [i ]
78
78
i += 1
79
- array [left ], array [i - 1 ] = array [i - 1 ], array [left ]
80
- return i - 1
79
+ array [left ], array [i - 1 ] = array [i - 1 ], array [left ]
80
+ return i - 1
81
81
82
82
83
83
# quick sort function
84
84
def quickSort (array , left , right , drawRect ):
85
85
if left < right :
86
86
pivot = partition (array , left , right , drawRect )
87
87
quickSort (array , left , pivot , drawRect )
88
- quickSort (array , pivot + 1 , right , drawRect )
88
+ quickSort (array , pivot + 1 , right , drawRect )
89
89
drawRect (array , [BLUE if x >= left and x < pivot
90
90
else YELLOW if x == pivot
91
91
else PURPLE if x > pivot and x <= right
@@ -98,7 +98,7 @@ def quickSort(array, left, right, drawRect):
98
98
# actually perform quicksort
99
99
def sort ():
100
100
try :
101
- quickSort (array , 0 , len (array )- 1 , drawRect )
101
+ quickSort (array , 0 , len (array ) - 1 , drawRect )
102
102
messagebox .showinfo ('Succces' , 'Array sorted!' )
103
103
except Exception :
104
104
messagebox .showinfo ('Error' , 'Array could not be sorted' )
0 commit comments