--- Scott David Daniels <[EMAIL PROTECTED]> wrote: > Anthony Liu wrote: > > mydict = {'the':358, 'they':29, 'went':7, > 'said':65} > > Is there an easy to sort this dictionary and get a > > list like the following (in decreasing order)? > Yes. > > def sortkey((word, frequency)): > return -frequency, word > > for word_freq in sorted(mydict.items(), key=sortkey): > print '%-6s %s' % word_freq >
Thank you scott, but 'sorted' itself is not a python library function. So I assume by "sorted(mydict.items()", you meant the object of mydict.items() which has been sorted, right? __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- http://mail.python.org/mailman/listinfo/python-list