How to sort a list? NOT a newbie question.

William Park opengeometry at yahoo.ca
Fri Sep 21 14:32:01 EDT 2001


On Fri, Sep 21, 2001 at 02:17:35PM -0400, Tim Peters wrote:
> Simpler is
> 
>     Cartesian_cmp = lambda a, b: cmp((a.real, a.imag), (b.real, b.imag))
> 
> That is, sequences in Python are compared lexicographically, and tuples are
> a sequence type; you don't have to fake lexicographic comparison by hand.
> 
> Notes:
> 
> + Python used to compare complex numbers that way.

Then, how does Python compare complex now?

-- 
William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
8 CPU cluster, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Sc.




More information about the Python-list mailing list