Carl Banks <pavlovevide...@gmail.com> writes: > On Dec 6, 4:17 pm, Steven D'Aprano <steve > +comp.lang.pyt...@pearwood.info> wrote: > > Nevertheless, I agree that in hindsight, the ability to sort such > > lists is not as important as the consistency of comparisons. > > I think that feeling the need to sort non-homogenous lists is > indictative of bad design.
It can also be indicative of code written for a Python that doesn't have sets. Comparing two list objects to see whether they have the same items in any sequence can be done with:: set(foolist) == set(barlist) but, if there is no ‘set’ type, it's fine to write:: sorted(foolist) == sorted(barlist) So there's no design error in wanting heterogenerous sequences to sort; it can be quite Pythonic (until the advent of the ‘set’ type). And, of course, that code needs to continue to work in Python 2.x; hence, the comparison of incompatible types cannot be fixed without breaking backward compatibility. Hence it's not fixed until Python 3.x. -- \ “All opinions are not equal. Some are a very great deal more | `\ robust, sophisticated and well supported in logic and argument | _o__) than others.” —Douglas Adams | Ben Finney -- http://mail.python.org/mailman/listinfo/python-list