code: def _update_sorting(self):
          key = self.key
          sorted_tops = self.sorted_tops
          tops = self.tops
          iterators = self.iterators
          for idx in self.idxs:
              try:
                  tops[idx] = next(iterators[idx])
                  top_key = key(tops[idx])
                  if top_key not in sorted_tops:
                      sorted_tops[top_key] = []
                  sorted_tops[top_key].append(idx)
              except StopIteration:
                  pass
          if len(sorted_tops) == 0:
              raise StopIteration
          key, self.idxs = sorted_tops.popitem(last=False)
          self.c_idx = 0