On Wednesday, January 25, 2012, Nils Bruin <nbr...@sfu.ca> wrote:
> On Jan 25, 9:22 am, Volker Braun <vbraun.n...@gmail.com> wrote:
>> On Wednesday, January 25, 2012 8:58:15 AM UTC-8, Nils Bruin wrote:
>>
>> > sage: bool(37 +i < 37 -i)
>> > False
>>
>> False meaning that Sage cannot affirm that it is true; IMHO the correct
>> answer.
>>
>> > sage: bool(37 +i > 37 -i)
>> > True
>>
>> BUG
> Having "<" return always false would actually be worse in practice.
> Then "sort" would not throw an error, but return unstable and
> implementation-dependent results.
>
> sorting a list L of complex numbers without relying on "__cmp__" being
> defined for complex numbers can by done via something along the lines
> of
>
> sorted(L,key=list)
>
> or
>
> sorted(L,key=lambda a: (a.real(),a.imag()))
>
> The problem gets worse if you have to devise a "key" function on a
> more heterogeneous collection of objects, though. If someone would
> come up with a reasonable candidate, we could call it "total_ordering"
> or something like that and then people would be able to invoke
>
> sorted(L,key=total_ordering)
>
> if they need to sort things without having to rely on arbitrary
> orderings invading into notation that suggests more algebraic meaning
> than is meant.

+1.  That's an explicit redescription of exactly what I mentioned above...

> --
> 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
>

-- 
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

-- 
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