KraftDiner <[EMAIL PROTECTED]> wrote:
> Many thanks everyone.
>
> One last quick question...
> The dictionary, I believe, is sorted by the key.
Dictionaries are NOT sorted -- they're hashtables.
> Is there a way to sort it by the value?
> Say I wanted to put out a list of the frequency sorted by highest to
> lowest?
import operator
for k, v in sorted(somedict, key=operator.itemgetter(1), reverse=1):
print k, v
emits key/value pairs, one per line, for any dictionary sorted by
descending order of values. Embellish to taste.
Alex
--
http://mail.python.org/mailman/listinfo/python-list