The docs for itertools.combinations state:
Combinations are emitted in lexicographic sort order. So, if the input iterable is sorted, the combination tuples will be produced in sorted order.
Elements are treated as unique based on their position, not on their value. So if the input elements are unique, there will be no repeat values in each combination.
[Emphasis mine]
What is the exact guarantee being made here? An empirical check shows that elements are always emitted as if by
for i in range(len(iterable)):
for j in range(i + 1, len(iterable)):
for k in range(j + 1, len(iterable)):
...
yield iterable[i], iterable[j], iterable[k], ...
What is the meaning of "lexicographixal order" in this case? In particular, I believe that the emphasized sentence is crucial, but I am not 100% of what the connection is. I think it means that the lexicographixal order is applied to the indices of the elements regardless of value, but I'd love to have someone confirm that.