MCPcopy Index your code
hub / github.com/python/cpython / partition

Function partition

Lib/turtledemo/sorting_animate.py:97–106  ·  view source on GitHub ↗
(shelf, left, right, pivot_index)

Source from the content-addressed store, hash-verified

95 shelf.insert(j, shelf.pop(imin))
96
97def partition(shelf, left, right, pivot_index):
98 pivot = shelf[pivot_index]
99 shelf.insert(right, shelf.pop(pivot_index))
100 store_index = left
101 for i in range(left, right): # range is non-inclusive of ending value
102 if shelf[i].size < pivot.size:
103 shelf.insert(store_index, shelf.pop(i))
104 store_index = store_index + 1
105 shelf.insert(store_index, shelf.pop(right)) # move pivot to correct position
106 return store_index
107
108def qsort(shelf, left, right):
109 if left < right:

Callers 2

test_partitionMethod · 0.85
qsortFunction · 0.85

Calls 2

insertMethod · 0.45
popMethod · 0.45

Tested by 1

test_partitionMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…