[Newbies] Re: how to sort by key a Dictionary object?
Overcomer Man
overcomer.man at gmail.com
Wed Aug 26 10:58:12 UTC 2009
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/4e2617df/attachment.htm
More information about the Beginners
mailing list