Debian Codegraph @

rpython/jit/tl/tinyframe/support.py

raw symbols SCIP
1
2 def partition(array, left, right):
3 last_item = array[right]
4 pivot = last_item[0]
5 storeindex = left
6 for i in range(left, right):
7 if array[i][0] <= pivot:
8 array[i], array[storeindex] = array[storeindex], array[i]
9 storeindex += 1
10 # Move pivot to its final place
11 array[storeindex], array[right] = last_item, array[storeindex]
12 return storeindex
13
14 def quicksort(array, left, right):
15 # sort array[left:right+1] (i.e. bounds included)
16 if right > left:
17 pivotnewindex = partition(array, left, right)
18 quicksort(array, left, pivotnewindex - 1)
19 quicksort(array, pivotnewindex + 1, right)
20
21 def sort(array):
22 quicksort(array, 0, len(array) - 1)