[BangPypers] sort query
bhaskar jain
bhaskar.jain2002 at gmail.com
Sat Oct 24 13:19:36 CEST 2009
Thanks all for replying.
Let me be clear,
>>> l = [2,1]
>>> id(l[0])
8402300
>>> id(l[1])
8402312
>>> l.sort()
>>> id(l[0])
8402312
>>> id(l[1])
8402300
So if we had [l] ------> [0] -----> 2
[1] -----> 1
after the sort, the index [0] binds to the '1' memory location and index
[1] binds to '2'.
Now if we have, d = {'a':1, 'b':2}
>>> l = d.keys().sort()
>>> print l
None
d.keys() is a list which references the keys of the dictionary.
But the sort method does not do what is intended on this list?
--Bhaskar.
More information about the BangPypers
mailing list