[Tutor] Dictionary, sorting -> list

Neil Conway neilconway@home.com
Sat, 04 Dec 1999 14:09:26 -0500 (EST)

Hello all.

First off, thanks to everyone who has answered questions of mine in the
past. You have all be very helpful.

My problem today is that I have a dictionary, like so:

>>> results = {}
>>> results['page1'] = 2
>>> results['page2'] = 4
>>> results['page3'] = 7

Given input like the above, I would like to return input like so:

#ranked from highest corresponding dict value to lowest

I need to do this for a large dictionary, which could be 1000 or more
items long. Is it possible to do this, somehow? Especially considering that
this will be run via CGI (its part of a search engine), I would
rather not have to do this in a slow, clumsy fashion.

I realize that this example would seem stupid, but I AFAICT, this is the way
it needs to be done - my actual dilemma is somewhat complex and difficult
than my example, obviously.

I've been thinking about this for a while, and haven't been able to come up
with a good solution.

Thanks in advance.
Neil Conway
Date: 04-Dec-1999
TIme: 13:59:47
For my GnuPG key, please see: