Ordered dictionary?

BW Glitch bwglitch at hotpop.com
Thu Jan 22 16:27:49 EST 2004


Leif K-Brooks wrote:

> I need to associate a string (key) with an integer (value). A dictionary 
> would do the job, except for the fact that it must be ordered. I also 
> need to look up the value for a specific key easily, so a list of tuples 
> wouldn't work.

A dictionary could be used. When you need to managed the items in order, 
what you would do is called dict.keys(), followed by a sort.

I don't know if this helps at all...

-- 
Glitch

http://andres980.tripod.com/

"That is the law of the jungle. The hunters and the hunted. Scrap or
be scrapped!"
"Animals hunt to SURVIVE!"
"And what do you think war is about?!"
         -- Dinobot and Tigatron, "The Law of the Jungle"



More information about the Python-list mailing list