generateFullSortedEntries = (entries, rankCompare, fullCompare) => {
  // @ts-expect-error XXX Key types
  assertRankSorted(entries, rankCompare);
  const { length } = entries;
  let i = 0;
  let sameRankIterator;
  return makeIterator(() => {
    if (sameRankIterator) {
      const result = sameRankIterator.next();
      if (!result.done) {
        return result;
      }
      sameRankIterator = undefined;
    }
    if (i < length) {
      const entry = entries[i];
      // Look ahead for same-rank ties.
      let j = i + 1;
      while (j < length && rankCompare(entry[0], entries[j][0]) === 0) {
        j += 1;
      }
      if (j === i + 1) {
        // No ties found.
        i = j;
        return harden({ done: false, value: entry });
      }
      const ties = entries.slice(i, j);
      i = j;

      // Sort the ties by `fullCompare`, enforce key uniqueness, and delegate to
      // a sub-iterator.
      // @ts-expect-error XXX Key types
      const sortedTies = sortByRank(ties, fullCompare);
      for (let k = 1; k < sortedTies.length; k += 1) {
        // @ts-expect-error XXX Key types
        const [key0] = sortedTies[k - 1];
        const [key1] = sortedTies[k];
        Math.sign(fullCompare(key0, key1)) ||
          Fail`Duplicate entry key: ${key0}`;
      }
      sameRankIterator = makeArrayIterator(sortedTies);
      return sameRankIterator.next();
    }
    return harden({ done: true, value: undefined });
  });
}
Refines a sequence of entries that is already sorted over its keys by the
`rankCompare` preorder, where there may be internal runs tied for the same
rank, into an iterable that resolves those ties using `fullCompare`.

@template [V=unknown]
@param {Array<[Key, V]>} entries
@param {RankCompare} rankCompare
@param {FullCompare} fullCompare
@returns {IterableIterator<[Key, V]>}