problem with sorting

Paddy paddy3118 at googlemail.com
Fri Mar 28 01:52:30 EDT 2008


On Mar 28, 5:38 am, ankitks.mi... at gmail.com 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]

Try:

from pprint import pprint as pp
pp(my_dict)


It works well for other built-in types too.

P.S it is not good to use a name, dict, that already has a use in
Python.

- Paddy.



More information about the Python-list mailing list