Richard A. O'Keefe
ok at atlas.otago.ac.nz
Sun Dec 2 23:35:55 UTC 2001
"James Stark" <james_stark03 at hotmail.com> wrote:
Yeah I want to be able to sort my records - thats why I want to put them
into a Array to sort - I thought of doing some sort of sort algorithm like
insertion sort - declaring this as a method.
We've beaten this very topic to death recently.
There is no point in writing your own sorting code (unless you have a
really snazzy new algorithm with some stunning advantage) because
Squeak already contains all the sorting code you need.
a := OrderedArray new.
a add: "something".
a add: "something else".
the last step here returns you a new collection with the same elements
as (a) but in sorted order.
[Is there any reason why #sort and its associated machinery couldn't
be in SequenceableCollection rather than ArrayedCollection?]
More information about the Squeak-dev