android/guava/src/com/google/common/collect/TreeBasedTable.java
@Override
  Iterator<C> createColumnKeyIterator() {
    final Comparator<? super C> comparator = columnComparator();

    final Iterator<C> merged =
        Iterators.mergeSorted(
            Iterables.transform(
                backingMap.values(),
                new Function<Map<C, V>, Iterator<C>>() {
                  @Override
                  public Iterator<C> apply(Map<C, V> input) {
                    return input.keySet().iterator();
                  }
                }),
            comparator);

    return new AbstractIterator<C>() {
      @NullableDecl C lastValue;

      @Override
      protected C computeNext() {
        while (merged.hasNext()) {
          C next = merged.next();
          boolean duplicate = lastValue != null && comparator.compare(next, lastValue) == 0;

          // Keep looping till we find a non-duplicate value.
          if (!duplicate) {
            lastValue = next;
            return lastValue;
          }
        }

        lastValue = null; // clear reference to unused data
        return endOfData();
      }
    };
  }
@Override
  Iterator<C> createColumnKeyIterator() {
    final Comparator<? super C> comparator = columnComparator();

    final Iterator<C> merged =
        Iterators.mergeSorted(
            Iterables.transform(
                backingMap.values(),
                new Function<Map<C, V>, Iterator<C>>() {
                  @Override
                  public Iterator<C> apply(Map<C, V> input) {
                    return input.keySet().iterator();
                  }
                }),
            comparator);

    return new AbstractIterator<C>() {
      @NullableDecl C lastValue;

      @Override
      protected C computeNext() {
        while (merged.hasNext()) {
          C next = merged.next();
          boolean duplicate = lastValue != null && comparator.compare(next, lastValue) == 0;

          // Keep looping till we find a non-duplicate value.
          if (!duplicate) {
            lastValue = next;
            return lastValue;
          }
        }

        lastValue = null; // clear reference to unused data
        return endOfData();
      }
    };
  }
Overridden column iterator to return columns values in globally sorted order.