On Tue, Jan 3, 2017 at 8:18 PM, Deborah Swanson <pyt...@deborahswanson.net> wrote: > OrderedDict is the new development I'd read about, but I think the key > order is just the order keys were added to the dict. The nice thing > about that though is when you loop over a dict you will always get the > key/value pairs in the same order, where with the standard dict they > come out in arbitrary order. Very disconcerting if you're watching the > loop as it progresses over muiltiple executions. I imagine you could > sort an OrderedDict so the keys originally added randomly would be put > into some kind of good order.
If you want a "SortedDict", you can get that fairly easily just by iterating over sorted(d) rather than simply d. You can also subclass the dictionary and change how it iterates, if you like. ChrisA -- https://mail.python.org/mailman/listinfo/python-list