code: def _siftup_max(heap, pos):
      'Maxheap variant of _siftup'
      endpos = len(heap)
      startpos = pos
      newitem = heap[pos]
      # Bubble up the larger child until hitting a leaf.
      childpos = 2*pos + 1    # leftmost child position
      while childpos < endpos:
          # Set childpos to index of larger child.
          rightpos = childpos + 1
          if rightpos < endpos and not heap[rightpos] < heap[childpos]:
              childpos = rightpos
          # Move the larger child up.
          heap[pos] = heap[childpos]
          pos = childpos
          childpos = 2*pos + 1
      # The leaf at pos is empty now.  Put newitem there, and bubble it up
      # to its final resting place (by sifting its parents down).
      heap[pos] = newitem
      _siftdown_max(heap, startpos, posf _siftup_max(heap, pos):
      'Maxheap variant of _siftup'
      endpos = len(heap)
      startpos = pos
      newitem = heap[pos]
      # Bubble up the larger child until hitting a leaf.
      childpos = 2*pos + 1    # leftmost child position
      while childpos < endpos:
          # Set childpos to index of larger child.
          rightpos = childpos + 1
          if rightpos < endpos and not heap[rightpos] < heap[childpos]:
              childpos = rightpos
          # Move the larger child up.
          heap[pos] = heap[childpos]
          pos = childpos
          childpos = 2*pos + 1
      # The leaf at pos is empty now.  Put newitem there, and bubble it up
      # to its final resting place (by sifting its parents down).
      heap[pos] = newitem
      _siftdown_max(heap, startpos, pos)
docs: Maxheap variant of _siftup