I have a kind of trie consisting of OrderedDicts (but in the wrong order) that looks like this:
test = {
'ab':{
'1':{},
'2':{
'002':{},
'001':{}}},
'aa':{
'02':{
'ac':{},
'01':{},
'ca':{},
'ab':{}},
'01':{
'b':{},
'z':{
'0':{},
'1':{}}}}
}
How can I get the full order of this dict at all subsequent levels?
If I use collections.OrderedDict (sorted (test.iteritems ())) , I only sort it for the first level.
I feel that I need to create a function that somehow calls itself recursively to the deepest level, but after I spent many hours on various ways to solve the problem, I'm still stuck here.
In the end, it should look like this:
test = {
'aa':{
'01':{
'b':{},
'z':{
'0':{},
'1':{}}},
'02':{
'01':{},
'ab':{},
'ac':{},
'ca':{}}},
'ab':{
'1':{},
'2':{
'001':{},
'002':{}}}
}