The new ValueTuple
types in C# 7 implement IComparable
, but the only documentation I have been able to find on their implementation of this simply states that CompareTo
's return value indicates relative position "in the sort order". It does not state what the "sort order" referred to actually is.
By examining the source, I can find that the order is what I would expect - it delegates to comparing the first field by its default Comparer
, then using the other fields one at a time, in order, to break ties. I would prefer not to depend on this without a guarantee that it's not considered an implementation detail that could change without violating specification, however.
Is this behavior actually documented anywhere?
System.ValueTuple
follows the same conventions asSystem.Tuple
, so you may want to see if that one was documented. – Fad