Python 3 removes canonical ordering of different types.  See 
http://docs.python.org/py3k/whatsnew/3.0.html#ordering-comparisons

I personally don't see any need to do this, but if you *really* need it, you 
could always do:

sorted(list_of_sympy_objects, key=hash)

and it will be canonical, at least on the same machine.  

Aaron Meurer
On Apr 1, 2010, at 6:10 AM, jegerjensen wrote:

> Brian and Vincent,
> Thanks for explaining.
> 
> If I understand you correctly, the decision is that a>b should only be
> used in the mathematical meaning. I have also learned (from Vincent I
> think) that cmp(a,b) will be removed from python 3.  What I don't
> understand then is how Sympy objects can be sorted?  If __lt__,
> __gt___, etc. are overloaded to construct objects, and __cmp__ is
> deprecated, what is the plan for canonical ordering?
> 
> Øyvind
> 
> On 31 Mar, 23:02, Vinzent Steinberg <[email protected]>
> wrote:
>> On Mar 30, 7:43 pm, Brian Granger <[email protected]> wrote:
>> 
>>> The reason is that the __nonzero__ methods of different Relational
>>> subclasses use the .compare method in different ways.  I didn't write
>>> this code, BUT I seem to remember that many tests fail if you simply
>>> have __nonzero__ return True.  I didn't investigate why, but my guess
>>> is that this is used to order different Relationals in expressions.
>> 
>> This is imho a bug that should be fixed. Such things should not be
>> used for ordering, this is not a clean approach and this should also
>> be fixed.
>> 
>> Vinzent
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/sympy?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to