[EMAIL PROTECTED] wrote: > On Mar 28, 1:57ÿam, raj <[EMAIL PROTECTED]> wrote: >> To ankit: >> >> Well, sort() doesn't return the sorted list. It returns None. Why not >> this straightforward way? >> dvals = dict.values() >> dvals.sort() >> print dvals > > Why not sorted( dict.values() ). >
If you are going to do it that way then it may be preferable to use itervalues: print sorted(dict.itervalues()) Both this and raj's suggestion create a single sorted list. Your suggestion creates two lists: the unsorted one and a separate sorted one. In most cases the difference is probably insignificant, but if you have a *lot* of values it might make a difference. -- http://mail.python.org/mailman/listinfo/python-list