An ordered dictionary for the Python library?

Mark Summerfield m.n.summerfield at
Sat Sep 15 07:10:02 CEST 2007

On 14 Sep, 21:23, James Stroud <jstr... at> wrote:
> Mark Summerfield wrote:
> > I guess I'll have to rename my module (although unfortunately, my book
> > has just gone into production and I have a (simpler) example of what I
> > considered to be an ordered dict, so I will be adding to the
> > terminology confusion). That notwithstanding, given that it is a
> > sorteddict, how is the API?
> I must think the API good because I have been implementing, in parallel
> with this discussion, my own "OrderedDict" with a very similar API (this
> is part of a larger project where I recently found the need to have a
> well-implemented ordered dict). The only real omission I see is to allow
> instantiating a "sorted dict" with an optional cmp function--to allow
> the generalization of such features as case-independence, etc.

I tend to create different orderings by munging the keys rather than
by having optional cmp functions (as you'll see in the
docstring). I've now put sorteddict on PyPI (with docs & tests):

I'm going offline for a week, so I'll see if there's any consensus or
progress when I'm back online, and then decide whether to do a PEP or

More information about the Python-list mailing list