[Haskell-cafe] Default Tuple Orderings

Martijn van Steenbergen martijn at van.steenbergen.nl
Sun Mar 15 04:08:17 EDT 2009


Mark Spezzano wrote:
> In other words my best guess is that the ordering of tuples is by 
> comparing the first tuple elements and then the seconds, thirds etc, 
> until there’s an element less than another.

...until there's an element not equal to the other, yes.

It finds the first position at which the two elements in the tuples are 
unequal and returns the result of comparing those two elements (LT or 
GT). If there's no such position, then the tuples are equal.

See also:

http://en.wikipedia.org/wiki/Lexicographical_order

HTH,

Martijn.


More information about the Haskell-Cafe mailing list