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.<br clear="all">
<br><span style="font-family:courier new,monospace">--</span><br style="font-family:courier new,monospace"><b style="font-family:courier new,monospace">Braga, Bruno</b><br style="font-family:courier new,monospace"><a style="font-family:courier new,monospace" href="http://www.brunobraga.net" target="_blank">www.brunobraga.net</a><br style="font-family:courier new,monospace">
<a style="font-family:courier new,monospace" href="mailto:bruno.braga@gmail.com" target="_blank">bruno.braga@gmail.com</a><br>
<br><br><div class="gmail_quote">On Tue, May 8, 2012 at 12:31 PM, bob gailer <span dir="ltr"><<a href="mailto:bgailer@gmail.com" target="_blank">bgailer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 5/7/2012 1:16 PM, Cranky Frankie wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
In 3.2.2 in IDLE I have this dictionary entry:<br>
<br>
Namath = {"first_name": "Joe", "last_name": "Namath", "phone": "<a href="tel:212-222-7777" value="+12122227777" target="_blank">212-222-7777</a>",\<br>
"email": "<a href="mailto:joe.namath@gmail.com" target="_blank">joe.namath@gmail.com</a>", "stadium": "Shea Stadium"}<br>
<br>
when I print it:<br>
<br>
print(Namath)<br>
<br>
I get:<br>
<br>
{'phone': '<a href="tel:212-222-7777" value="+12122227777" target="_blank">212-222-7777</a>', 'first_name': 'Joe', 'last_name': 'Namath',<br>
'email': '<a href="mailto:joe.namath@gmail.com" target="_blank">joe.namath@gmail.com</a>', 'stadium': 'Shea Stadium'}<br>
<br>
Why is it out of order?<br>
</blockquote>
<br>
May I recommend a different approach to such questions.<br>
<br>
When you get an unexpected (undesired) result try saying - "Oh I see - that's how Python does it!"<br>
<br>
I want something different. How can I get it?<br>
<br>
Then try reading the documentation.<br>
<br>
Asking why does it not do what I want is not IMHO the best way to win friends here.<br>
<br>
Taking this steps further<br>
- what does it mean to be "in order". To some it is the order in which items are added rather than some collating sequence.<br>
- Do you want order by key or by value?<br>
- how would you order {1 : 'cat', "a": 3, (2,3): True}?<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Bob Gailer<br>
<a href="tel:919-636-4239" value="+19196364239" target="_blank">919-636-4239</a><br>
Chapel Hill NC<br>
<br>
______________________________<u></u>_________________<br>
Tutor maillist - <a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/tutor</a><br>
</font></span></blockquote></div><br>