Thomas Bellman wrote: > Steve Holden <[EMAIL PROTECTED]> wrote: > >> Only half the number, of course. The advantage of the key function is >> that each element requires only one call out to a Python function, and >> the comparisons then take place using a C-coded comparison function. > > You don't need any Python-coded function at all. The operator > module is your friend: key=operator.attrgetter('real', 'imag') > will create the required tuples for sorting. > True; "requires only one call out to the key function", then. You're right, attrgetter will be faster still, and it's a really neat solution.
regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ -- http://mail.python.org/mailman/listinfo/python-list