On 12/19/05, Jim Jewett <jimjjewett at gmail.com> wrote: > Unfortunately, one very common use case of comparisons is to get a > canonical order. If the order is sensible, all the better, but that > is not strictly required. One of Python's selling points (especially > compared to Java) is that getting a canonical order "just works", even > if the objects being sorted are not carefully homogenized by hand. > Python itself relies on this when comparing same-length dictionaries. While I agree that this is a useful property, and I'd like it to be true, it isn't even today: >>> import Numeric >>> a = Numeric.array((1,2,3)) >>> a array([1, 2, 3]) >>> sorted([a, (1,2,3), 1, 2, '123']) Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: function not supported for these types, and can't coerce to supported types >>> a < '123' Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: function not supported for these types, and can't coerce to supported types >>> Numeric arrays are the canonical example of an "awkward case" when discussing comparisons... OTOH, I'm not sure I want to see more "awkward cases" added. Paul.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4