On Sun, Jun 16, 2013 at 7:25 PM, Jim Mooney <cybervigila...@gmail.com> wrote: > On 15 June 2013 23:30, Dave Angel <da...@davea.name> wrote: > >>>> The sort() method doesn't work, but sorted does. > > How many times have I read you can't sort a dictionary in Python. Was > I just misreading or was that true of older Pythons?
Dicts have no order: >>> {'b': 'c', 'a': 'z'} {'a': 'z', 'b': 'c'} Moreover, the sorted() function sorts the keys only (something that list() does anyway). If you are looking for a way to have dicts with an order of keys (and you don’t need that most of the time), look at collection.OrderedDict. -- Kwpolska <http://kwpolska.tk> | GPG KEY: 5EAAEA16 stop html mail | always bottom-post http://asciiribbon.org | http://caliburn.nl/topposting.html _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor