I'm having trouble understanding the following code (a snippetof a code). What does it do? The whole code is about comparingefficiencies of different algorithms.
def partition(list,first,last):
piv = list[first]
lmark = first+1
rmark = last
done = False
while not done:
while lmark <= rmark and list[lmark]<=piv:
lmark=lmark+1
while list[rmark]>=piv and rmark>=lmark:
rmark=rmark-1
if rmarkdone = True
else:
temp = list[lmark]
list[lmark]=list[rmark]
list[rmark]=temp
temp = list[first]
list[first]=list[rmark]
list[rmark]=temp
return rmark