sort() doesn't work on dist.keys() ?

Steve Pinard spinard at ra.rockwell.com
Thu Jul 10 22:14:01 CEST 2003


(Got a comm error trying to post first time, sorry if this
is a duplicate)

New to Python, so please bear with me.

>>> import sys
>>> print sys.modules.keys()          # works fine
['code', ...snip... ]
>>> print sys.modules.keys().sort()   # returns None, why?
None

According to my reference (Nutshell), keys() returns a
"copy" of the dict keys as a list, so I would expect when
I aply sort() to that list, I would get an in-place sorted
version of that list.  Why do I get None?

TIA,
- Steve




More information about the Python-list mailing list