otherwisewe simply return the index of the lesser of the two childrenelif self heap[ * self heap[ * + ]return elsereturn now we can create the sink functiondef sink(selfk)as beforewe are going to loop so that we can sink our element down as far as is neededwhile <self sizenext we need to know which of the left or the right child to compare against this is where we make use of the minindex(functionmi self minindex(kas we did in the float(methodwe compare parent and child to see whether we need to swapif self heap[kself heap[mi]self heap[ ]self heap[miself heap[mi]self heap[kand we need to make sure that we move down the tree so that we don' get stuck in loopk mi the only thing remaining now is to implement pop(itself this is very straightforward as the grunt work is performed by the sink(methoddef pop(self)item self heap[ self heap[ self heap[self sizeself size - self heap pop(self sink( return item