>
>
> It's a little silly that people have read python's requirements as "any 
> two objects need to have "<" defined on them because "sorted" should always 
> work. We already know that we won't get consistent results in sage anyway 
> if we try to implement this (because there are domains where we absolutely 
> have to follow a mathematically meaningful ordering) and in any case, this 
> design decision has been abandoned in python 3 anyway:
>
> >>> L=[complex(1,2),complex(3,4)]
> >>> sorted(L)
> TypeError: unorderable types: complex() < complex()
>
> Since specifying a key is so dead simple anyway, we should put the onus on 
> the user of sort to ensure that the sort command will succeed:
> >>> sorted(L,key=str)
> [(1+2j), (3+4j)]
>
> and do away with all the arbitrary ordering implementations and deal with 
> the errors instead. Raised errors are much preferrable over some arbitrary 
> results, in my opinion.
>

It's even bad in Python 2.X:

sage: complex("2+j") < complex("2+2j")
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-80cc6d835806> in <module>()
----> 1 complex("2+j") < complex("2+2j")

TypeError: no ordering relation is defined for complex numbers
sage: L = [complex("2+j"), complex("2+2j")]
sage: sorted(L)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-8-d66b4ccec544> in <module>()
----> 1 sorted(L)

TypeError: no ordering relation is defined for complex numbers

My opinion, which is based solely on the above discussion (because I don't 
know the math) is that if we define a specific embedding into the reals 
(which would be part of the parent), we should be able to do the 
comparison. If their is no specific embedding, the comparison is not 
well-defined, so raise an error.

Best,
Travis

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to