Anthony Liu wrote:
--- Scott David Daniels <[EMAIL PROTECTED]> wrote:
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.
For older Pythons:
base = [(-frequency, word) for word, frequency in mydict.items()]
base.sort()
for negated_frequency, word in base:
print '%-6s %s' % (word, -negated_frequency)
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list