This is my code :
a = {0:'000000',1:'11111',3:'333333',4:'444444'}
for i in a:
print i
it shows:
0
1
3
4
but I want it to show:
4
3
1
0
so, what can I do?
The order keys are iterated in is arbitrary. It was only a coincidence that they were in sorted order.
>>> a = {0:'000000',1:'11111',3:'333333',4:'444444'}
>>> a.keys()
[0, 1, 3, 4]
>>> sorted(a.keys())
[0, 1, 3, 4]
>>> reversed(sorted(a.keys()))
<listreverseiterator object at 0x02B0DB70>
>>> list(reversed(sorted(a.keys())))
[4, 3, 1, 0]