<br><br><div class="gmail_quote">On Fri, Jan 16, 2009 at 9:15 AM, Kent Johnson <span dir="ltr">&lt;<a href="mailto:kent37@tds.net">kent37@tds.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="Ih2E3d">On Thu, Jan 15, 2009 at 3:44 PM, Jervis Whitley &lt;<a href="mailto:jervisau@gmail.com">jervisau@gmail.com</a>&gt; wrote:<br>
&gt; how about this:<br>
&gt; items = [(1,&#39;a&#39;),(1,&#39;b&#39;),(2,&#39;a&#39;),(3,&#39;a&#39;),<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (3,&#39;b&#39;),(4,&#39;a&#39;),(5,&#39;a&#39;),(5,&#39;b&#39;),(5,&#39;c&#39;)]<br>
&gt; mydict = dict(items)<br>
&gt; items = [item for item in mydict.iteritems()]<br>
<br>
</div>That only coincidentally preserves order; the order of items in a<br>
dictionary is, for practical purposes, unpredictable.<br>
<br>
BTW [item for item in mydict.iteritems()] can be written as just mydict.items().<br>
<font color="#888888"><br>
Kent</font></blockquote><div>I realise that what you have said is true, however&nbsp;</div></div>can you show me a case where&nbsp;<div><br></div><div>&gt; items = dict(items).items()<br></div><div><br></div><div>will not preserve order? Thanks.</div>