On Mar 28, 5:38 am, [EMAIL PROTECTED] wrote: > >>> dict = {'M':3, 'R':0, 'S':2} > >>> print dict > > {'S': 2, 'R': 0, 'M': 3} > > now if I wanted sorted values in list, i am not able to do this>>> print > dict.values().sort() > > None > > it returns None instead of [0, 2, 3]
The sort method works by sorting 'in place'. That means it doesn't return the sorted value, but just sorts the sequence. >>> t = {'M':3, 'R':0, 'S':2} >>> x = t.values() >>> x.sort() >>> x [0, 2, 3] or you can use sorted(), which does return the sorted sequence: >>> sorted(t.values()) [0, 2, 3] -- http://mail.python.org/mailman/listinfo/python-list