This question has been asked many times, and I searched diligently to no avail. Here is an example of my question:
dict = {"a":"1", "b":"2", "c":"3"}
The output I am looking for is as below:
dict = {"c":"3", "b":"2", "a":"1"}
I am really unsure how to attack this, as here is my current code:
def reorder(a):
clean = {}
pair = {}
i = 0
for k, v in a.iteritems():
pair = a.popitem()
#Do stuff here
return clean
What I am currently doing is grabbing the tuple pair as a key/value, as these need to remain the same. I am not sure how to insert this pair in a reverse order though.