I know I'm gonna feel dumb in the Morning....

Peter Hansen peter at engcorp.com
Fri May 23 12:43:13 EDT 2003


"Edward K. Ream" wrote:
> 
> > What I really want to do is,
> >
> >     for f in _fromDict.keys().sort():
> 
> Do this:
> 
> _fromDict.keys().sort()
> for f in _fromDict.keys():
>     etc.

You mean this, I think:

keyList = _fromDict.keys()
keyList.sort()
for f in keyList:
   etc.


Otherwise, each time you call _fromDict.keys() you will regenerate the 
unsorted list...

-Peter




More information about the Python-list mailing list