Newbie Questions: Swithing from Perl to Python
Roy Smith
roy at panix.com
Sat Oct 25 22:16:35 EDT 2003
More information about the Python-list mailing list
Sat Oct 25 22:16:35 EDT 2003
- Previous message (by thread): Newbie Questions: Swithing from Perl to Python
- Next message (by thread): Newbie Questions: Swithing from Perl to Python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Todd Stephens <huzzah at tampabay.rr.com> wrote: > I am not sure how to print a sorted list from a dictionary. I think this would probably involve > assigning the dictionary elements to a list, then printing the sorted > list(s). Exactly. keys = myDict.keys() keys.sort() for key in keys: print key My personal opinion is that you should be able to do the simplier: for key in myDict.keys().sort() print key but unfortunately, sort doesn't work like that. It sorts the list in-place and does NOT return the sorted list.
- Previous message (by thread): Newbie Questions: Swithing from Perl to Python
- Next message (by thread): Newbie Questions: Swithing from Perl to Python
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list