
"BJörn Lindqvist" <bjourne@gmail.com> wrote in message news:740c3aec0704202128g6537c5bfv94c0f60a5d883d76@mail.gmail.com...
On 4/20/07, Terry Reedy <tjreedy@udel.edu> wrote:
2. Order in the sorting or collation sense, which I presume you mean. To reduce confusion, call this a sorted dictionary, as others have done.
Regardless, this has the problem that potential keys are not always comparable.
Current example:
[1, 1j].sort()
Traceback (most recent call last): File "<pyshell#2>", line 1, in -toplevel- [1, 1j].sort() TypeError: no ordering relation is defined for complex numbers
This will become worse when most cross-type comparisons are disallowed in 3.0.
l = [(), "moo", 123, []] l.sort() l [123, [], 'moo', ()]
Py 3.0 will raise an exception here as these will all be incomparable.
If it is not a problem for lists it is not a problem for ordered dictionaries.
But it *is* currently a problem for lists that will become much more extensive in the future, so it *is* currently a problem for sorted dicts that will be much more of a problem in the future. Hence, sorted dicts will have to be restricted to one type or one group of truly comparable types. Terry Jan Reedy