Put it simple, dictionaries do not sort. You can use the dict.keys() to get a list of the dictionary keys, then sort them... there are lots of talks on this, just google a bit, and you will find fancy ways to do key or value sorting.
-- *Braga, Bruno* www.brunobraga.net bruno.br...@gmail.com On Tue, May 8, 2012 at 12:31 PM, bob gailer <bgai...@gmail.com> wrote: > On 5/7/2012 1:16 PM, Cranky Frankie wrote: > >> In 3.2.2 in IDLE I have this dictionary entry: >> >> Namath = {"first_name": "Joe", "last_name": "Namath", "phone": " >> 212-222-7777",\ >> "email": "joe.nam...@gmail.com", "stadium": "Shea Stadium"} >> >> when I print it: >> >> print(Namath) >> >> I get: >> >> {'phone': '212-222-7777', 'first_name': 'Joe', 'last_name': 'Namath', >> 'email': 'joe.nam...@gmail.com', 'stadium': 'Shea Stadium'} >> >> Why is it out of order? >> > > May I recommend a different approach to such questions. > > When you get an unexpected (undesired) result try saying - "Oh I see - > that's how Python does it!" > > I want something different. How can I get it? > > Then try reading the documentation. > > Asking why does it not do what I want is not IMHO the best way to win > friends here. > > Taking this steps further > - what does it mean to be "in order". To some it is the order in which > items are added rather than some collating sequence. > - Do you want order by key or by value? > - how would you order {1 : 'cat', "a": 3, (2,3): True}? > > -- > Bob Gailer > 919-636-4239 > Chapel Hill NC > > ______________________________**_________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor> >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor