Why are there no ordered dictionaries?

bonono at gmail.com bonono at gmail.com
Mon Nov 21 00:12:52 EST 2005


Bengt Richter wrote:
> On Sun, 20 Nov 2005 22:03:34 +0100, Christoph Zwerschke <cito at online.de> wrote:
> >> Ordering the keys isn't the normal case, and can be done easily when
> >> needed.
> >
> >That depends. Maybe I do not want the keys to be sorted alphabetically,
> >but according to some criteria which cannot be derived from the keys
> >themselves.
> You mean involving also the values? What's wrong with
>     sorted(plaindict.items(), key=your_ordering_function) ?
>
Not according to the content of the data, not just the "key". Or in
other words, some other metadata that is not present in the data. A
typical thing, like order of creation. Or some arbitary order. For
example :

I present a data grid/table in a HTML form and the user just drag and
drop and rearrange the columns order.

Of course, you may say, just put another column that represent
this(some reporting programs I have seen do it this way) and that is an
option but not the only option.




More information about the Python-list mailing list