File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change 1212from __future__ import print_function
1313
1414
15- def quick_sort (ARRAY ):
15+ def quick_sort (collection ):
1616 """Pure implementation of quick sort algorithm in Python
1717
1818 :param collection: some mutable ordered collection with heterogeneous
@@ -29,14 +29,14 @@ def quick_sort(ARRAY):
2929 >>> quick_sort([-2, -5, -45])
3030 [-45, -5, -2]
3131 """
32- ARRAY_LENGTH = len (ARRAY )
33- if ( ARRAY_LENGTH <= 1 ) :
34- return ARRAY
32+ length = len (collection )
33+ if length <= 1 :
34+ return collection
3535 else :
36- PIVOT = ARRAY [0 ]
37- GREATER = [ element for element in ARRAY [1 :] if element > PIVOT ]
38- LESSER = [ element for element in ARRAY [1 :] if element <= PIVOT ]
39- return quick_sort (LESSER ) + [PIVOT ] + quick_sort (GREATER )
36+ pivot = collection [0 ]
37+ greater = [element for element in collection [1 :] if element > pivot ]
38+ lesser = [element for element in collection [1 :] if element <= pivot ]
39+ return quick_sort (lesser ) + [pivot ] + quick_sort (greater )
4040
4141
4242if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments