[Tutor] Keeping Dictonary Entries Ordered

Eric Dorsey dorseye at gmail.com
Fri Feb 13 03:13:36 CET 2009


>>>> But you need to have an order that will work with sorted().
> Its not just the order you add items to the dict. To store an
> arbitrary order I suspect you would need to maintain a
> secondary list with the keys in the order of insertion.
> The most reliable way to dop that would be to subclass
> dict. Somebody may already have done that so its worth
> a google...
>
> HTH,
>

Alan, can you give a short snippet of what that would look like?  I was
trying to code out some idea of how you'd retain insertion order using
another dict or a list and didn't get anywhere.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090212/e5752df2/attachment-0001.htm>


More information about the Tutor mailing list