On Tue, Nov 9, 2021 at 11:05 PM Paul Bryan <pbryan@anode.ca> wrote:
On Tue, Nov 09, 2021 at 10:01:35PM -0800, Christopher Barker wrote:
What are use cases for sorted dicts?

Good question :-)

It could be handy for deterministic iteration of its values, for example to  allow serialized values to be easily compared, or to generate and verify a signatures.

Yup -- I've done that. But for that, it's fine to sort when you are doing the comparing / serialization. What I haven't been able to imagine is a use case for keeping a
Mapping sorted constantly as you insert / remove items. For that you'd need a use case where you were making sorted queries of various sorts. I noticed, for instance, that the Java implementation posted earlier had methods like "all the items after this one" (can't remember how that was spelled).

I'm sure there are use cases for this, I'm probably lacking imagination :-)


Christopher Barker, PhD (Chris)

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython