Tim Chase wrote:
> orderedDict = [(k,mydict[k]) for k in mydict.keys().sorted()]

Wrong. As you stated, sorted() is a function, not a method.

orderedListOfTuples = [(k,mydict[k]) for k in sorted(mydict.keys())]

It's great that many people try to help out on comp.lang.python,
the community won't survive otherwise, but I think it's important
to test answers before posting them, unless you're sure about your
answer. A wrong answer might actually be worse than no answer at
all. I fear that newbies will just get scared off if they get bunch
a of replies to their questions, and most are wrong.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to