Marcin 'Qrczak' Kowalczyk wrote:
2008/11/11 Greg Ewing <[EMAIL PROTECTED]>:

It would be possible to implement this convention in the
sort method

Until someone wishes to sort a list of some objects by key, where the
keys can be (1, None) compared with (1, 3).

Yes, I thought of that shortly after posting. Lists and
tuples could be special-cased as well, although someone
is inevitably going to be surprised when their favourite
sequence type doesn't get included in the special
treatment.

However, covering lists and tuples would cover the vast
majority of use cases, I think. So perhaps the best
thing would be to provide this as an option, defaulting
to false, and with the limitations clearly documented.
If someone has a use case not covered by it, they just
have to provide their own key function.

Another approach would be to define a protocol for
comparison-for-sorting, which custom types could implement
if they wanted.

--
Greg
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to