Can I get JSON to load into an OrderedDict?
Ok so I can use an OrderedDict in json.dump. That is, an OrderedDict can be used as an input to JSON.
Ok so I can use an OrderedDict in json.dump. That is, an OrderedDict can be used as an input to JSON.
I am having some trouble using the collections.OrderedDict class. I am using Python 2.7 on Raspbian, the Debian distro for Raspberry Pi. I am trying to print two dictionaries in order for comparison (side-by-side) for a text-adventure. The order is essential to compare accurately.
No matter what I try the dictionaries print in their usual unordered way.
I’m trying to sort OrderedDict in OrderedDict by ‘depth’ key.
Is there any solution to sort that Dictionary ?
Update: dicts retaining insertion order is guaranteed for Python 3.7+