rent <[EMAIL PROTECTED]> writes: > keys = freq.keys() > keys.sort(key = freq.get, reverse = True) > for k in keys: > print "%-10s: %d" % (k, freq[k])
I prefer (untested): def snd((x,y)): return y # I wish this was built-in sorted_freq = sorted(freq.iteritems(), key=snd, reverse=True) for k,f in sorted_freq: print "%-10s: %d" % (k, f) -- http://mail.python.org/mailman/listinfo/python-list