I have an existing OrderedDict dictionary and I want to print out the keys in the original order of the dictionary.
All the key/value pairs were created at one time not one at a time like in most other examples on stackoverflow.
Here is the code:
test_dict = collections.OrderedDict()
test_dict = {
'a':'A',
'e':'E',
'c':'C'
}
for key in test_dict:
print key
And I get the result:
a
c
e
But I want to get:
a
e
c
Why is OrderedDict not keeping the original order? Is there any other way to keep original order of an existing dictionary?