Thanks Bert<br><br>That explanation was really useful and the length to which you went in describing the &quot;solution&quot; process you went through is appreciated.<br><br>Regards<br><br><div class="gmail_quote">2009/8/26 Bert Freudenberg <span dir="ltr">&lt;<a href="mailto:bert@freudenbergs.de">bert@freudenbergs.de</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div style="word-wrap: break-word;"><div><div class="im"><div>On 25.08.2009, at 23:52, r00t uk wrote:</div>
<br><blockquote type="cite">Bert - I don&#39;t think creating a Squeak version of that would have helped anybody new to squeak/smalltalk.</blockquote><div><br></div></div><div>Right, in this case not, but that&#39;s not what I meant primarily. Should have changed the subject and moved to squeak-dev, sorry. I&#39;ll make up for it, see below [*].</div>
<div><br></div><div>I meant that I&#39;ve never seen a graphical explanation of what Randal did in these &quot;few minutes&quot; to find out. It&#39;s what experienced Smalltalkers do all the time, and Squeak provides powerful ways of finding out about itself, but they are not obvious to newbies.</div>
<div><br></div><div>Usually we don&#39;t even mention that it took us a minute to find out, so beginners get the impression that it&#39;s &quot;all in our heads&quot;. It&#39;s not (not *all* anyway) but the tools allow us to find out quickly. Faster than looking up documentation indeed, which we can&#39;t really proof because of the lack of it ;)</div>
<div class="im"><div><br></div><blockquote type="cite">  Cookbook wiki maybe?<br><br><br><div class="gmail_quote">2009/8/25 Bert Freudenberg <span dir="ltr">&lt;<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>&gt;</span><br>
 <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><br> On 25.08.2009, at 23:31, Randal L. Schwartz wrote:<br> <br> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
 There might be a far better way.. but I found this in a few minutes.<br> </blockquote> <br> <br></div> Someone should make a Squeak version of<br> <br>        <a href="http://xkcd.com/627/" target="_blank">http://xkcd.com/627/</a><br>
 <br> - Bert -<br><br></blockquote></div></blockquote></div></div><div><span style="border-collapse: separate; border-spacing: 0px; color: rgb(0, 0, 0); font-family: Lucida Grande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div style="word-wrap: break-word;">
<div style="font-family: Helvetica;"><font face="&#39;Lucida Grande&#39;"><span style="font-size: medium;"><font face="Helvetica"><font face="&#39;Lucida Grande&#39;"><font face="Helvetica"><br></font></font></font></span></font></div>
<div style="font-family: Helvetica;"><span style="font-size: medium;"><br></span></div><div style="font-family: Helvetica;"><span style="font-size: medium;">[*] Here&#39;s what I&#39;d do:</span></div><div style="font-family: Helvetica;">
<span style="font-size: medium;"><br></span></div><div style="font-family: Helvetica;"><span style="font-size: medium;">Make a little test case in a workspace:</span></div><div style="font-family: Helvetica;"><span style="font-size: medium;"><br>
</span></div><div style="font-family: Helvetica;"><span style="font-size: medium;">| dict |</span></div><div style="font-family: Helvetica;"><span style="font-size: medium;"><div>dict := {&#39;a&#39; -&gt; &#39;first&#39;. &#39;b&#39; -&gt; &#39;second&#39;. &#39;c&#39; -&gt;&#39;third&#39;} as: Dictionary.</div>
<div>dict </div><div><br></div><div>This intentionally does not use integers as keys, because that&#39;s what&#39;s special about Dictionaries. (and in fact I didn&#39;t really open a workspace but typed it right in the browser I happened to have open. Saves a second)</div>
<div><br></div><div>When I printed the expression above, the elements *were* sorted by key. So this may be chance, but I wanted to see. So I double-clicked Dictionary, pressed cmd-b to bring up a browser, clicked in the right pane with all the methods, and pressed p, to find printing-related methods (I should have clicked the &quot;printing&quot; protocol but usually methods are named more sanely than they are categorized). Anyway this took me right to the &quot;printElementsOn: aStream&quot; which indeed sorts. That could be a template for your own solution.</div>
<div><br></div><div>But in any case the print string of the dictionary is not helpful to show the problem. So:</div><div><br></div><div><span style="font-family: &#39;Lucida Grande&#39;; font-size: 12px;"><div style="font-family: Helvetica;">
<span style="font-size: medium;">| dict |</span></div><div style="font-family: Helvetica;"><span style="font-size: medium;"></span></div></span><div>dict := {&#39;a&#39; -&gt; &#39;first&#39;. &#39;b&#39; -&gt; &#39;second&#39;. &#39;c&#39; -&gt;&#39;third&#39;} as: Dictionary.</div>
<div>dict asArray</div><div><br></div><div>Yes, this printed #(&#39;second&#39; &#39;third&#39; &#39;first&#39;), so now we need to sort. I have the idiom in my head but I typed in in anyway to verify</div><div><br></div>
<div><div>| dict  |</div><div>dict := {&#39;a&#39; -&gt; &#39;first&#39;. &#39;b&#39; -&gt; &#39;second&#39;. &#39;c&#39; -&gt;&#39;third&#39;} as: Dictionary.</div><div>dict keys asSortedCollection collect: [:key | dict at: key]</div>
<div><br></div><div>And this indeed gives  an OrderedCollection(&#39;first&#39; &#39;second&#39; &#39;third&#39;)</div><div><br></div><div>So if I had sent an answer to your question I probably would have just pasted the line</div>
<div><br></div><div><span style="white-space: pre;">        </span>dict keys asSortedCollection collect: [:key | dict at: key]</div><div><br></div><div>not even mentioning that it took me a minute to verify, and that en passant I discovered that dictionary printing is sorted for a couple of years already, which I had not noticed ;)</div>
<div><br></div><div>Comparing this to Randal&#39;s suggestion I&#39;d say that mine feels more &quot;Smalltalky&quot;. Accessing the associations in a dictionary directly feels unclean. Maybe because it breaks the abstraction, associations are an implementation detail of dictionaries. It&#39;s unlikely this will ever change and accessing the associations is fine, but still ;)</div>
<div><br></div><font color="#888888"><div>- Bert -</div></font></div></div></span></div></div></span></div></div><br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@lists.squeakfoundation.org">Beginners@lists.squeakfoundation.org</a><br>
<a href="http://lists.squeakfoundation.org/mailman/listinfo/beginners" target="_blank">http://lists.squeakfoundation.org/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br>