[Newbies] Re: how to sort by key a Dictionary object?

Overcomer Man overcomer.man at gmail.com
Wed Aug 26 11:02:14 UTC 2009


Opps!  An early morning typo.

The correct sorted answer is:

a Dictionary('1a'->'object 1a' '2b'->'object 2b' '3c'->'object 3c' )

On Wed, Aug 26, 2009 at 3:58 AM, Overcomer Man <overcomer.man at gmail.com>wrote:

> I know this was already covered but to simplify the explination for the
> beginner:
>
> Sort is automatic for Dictionaries.
>
> | dict |
> dict := Dictionary new.
> dict at: '3c' put: 'object 3c'.
> dict at: '1a' put: 'object 1a'.
> dict at: '2b' put: 'object 2b'.
> dict
>
> Evaluating the code with "Print It" will respond:
> a Dictionary('1a'->'object 1a' '2b'->'object 2a' '3c'->'object 3a' )
>
> ----------------------
>
> A useful capability of Dictionaries is merging files by key.
> Add old objects then overwriting with new objects and sorting is automatic.
>
> | dict |
> dict := Dictionary new.
> dict at: '3c' put: 'object 3c'.
> dict at: '1a' put: 'object 1a'.
> dict at: '3c' put: 'new object 3c'.
> dict
>
>  a Dictionary('1a'->'object 1a' '3c'->'new object 3c' )
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20090826/bf352c35/attachment.htm


More information about the Beginners mailing list