code: def update(self, old, new):
          
          i = self.rank[old]     # change value at index i
          del self.rank[old]
          self.heap[i] = new
          self.rank[new] = i
          if old < new:          # maintain heap order
              self.down(i)
          else:
              self.up(i)
docs: Replace an element in the heap