How to sort a list? NOT a newbie question.

Brian Quinlan BrianQ at ActiveState.com
Mon Sep 17 20:26:57 EDT 2001


Greg wrote:
> I don't think that's true. The sort() method could first look
> for a __cmp__ method, and __cmp__ for complex numbers could
> impose an arbitary ordering, independently of what <, >, <=,
> >= do.

But what would the point be? The current implementation is telling you
that there is no meaningful sort order that it can impose. If you have
some sort order in mind then you should use that by providing your own
comparison function. If not, why are you bothering with the sort?

Cheers,
Brian





More information about the Python-list mailing list