On Tue, Oct 12, 2010 at 1:52 PM, Josep M. Fontana <josep.m.font...@gmail.com
> wrote:

> Thanks Chris and Alan,
>
> OK, I see. Now that I managed to build the dictionary, I did a print to
> confirm that indeed the dictionary was created and it had the intended
> contents and I was surprised to see that the order of the items in it was
> totally changed. So the text file from which the dictionary was created was
> sorted in alphabetical order ('A-01,1334', 'A-02,1234',...'I-01,1334'...),
> but when I print the dictionary, I get: {'I-02': '1399', 'I-01': '1374',
> 'D-09': '1524', 'I-07': '1399' .....}
>
> I don't think this will be a problem for what I want to do next but I'm
> curious to know why the order is all changed in a way that doesn't seem to
> be very intuitive.
>

Here is a discussion of how to iterate over a dictionary in sorted order:

http://stackoverflow.com/questions/364519/in-python-how-to-i-iterate-over-a-dictionary-in-sorted-order




-- 
Joel Goldstick
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to