SortedCollection

Joey Gibson joey at joeygibson.com
Wed May 2 18:48:17 UTC 2001


On Wed, 2 May 2001 12:18:32 -0600 (MDT), Jeff Shipman <shippy at nmt.edu>
wrote:

||| I would like to do a descending sort on a
||| SortedCollection. How could I do this?

oc _ #(1 2 3 4 5) asOrderedCollection.
sc _ oc asSortedCollection: [:x :y| x > y]

should do the trick. (Deoending on what you want to sort, of course.)

If you've already got a SortedCollection, send in a new sort block using
the #sortBlock: message. For example the above SC is sorted descending, but
sending sc this: sortBlock: [:x :y| x < y] would reverse the sort.

Joey





More information about the Squeak-dev mailing list