The problem of "<" not providing a total ordering seems to come up
again and again in different situations. There are two cases now
already where it is clear that even in Python "<" does not signify a
total ordering anymore:

 - python complex numbers ( < gives an error)
 - python sets ( < denotes proper inclusion)

Rather than keep trying to work around this by trying to impose rather
arbitrary total orderings in categories, wouldn't it be more natural
to recognise that sorting doesn't make canonical sense in all
categories and be explicit about the choice of injection from the set
to be sorted into a totally ordered set? The "key" attribute for sort
allows for exactly such a choice.

sage: L=[set([1,2,3]),set([3,2]),set([1,4])]
sage: L
[set([1, 2, 3]), set([2, 3]), set([1, 4])]
sage: L.sort()
sage: L
[set([2, 3]), set([1, 2, 3]), set([1, 4])]
sage: L.sort(key=lambda V: [len(V),sorted(V)])
sage: L
[set([1, 4]), set([2, 3]), set([1, 2, 3])]
sage: L.sort(key=lambda V: sorted(V))
sage: L
[set([1, 2, 3]), set([1, 4]), set([2, 3])]

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to