SortedCollection

Randal L. Schwartz merlyn at stonehenge.com
Wed May 2 19:27:02 UTC 2001


>>>>> "Stephen" == Stephen Pair <spair at advantive.com> writes:

Stephen> You could also define ordering methods on your objects for the more complex
Stephen> cases:

Person> preceedsByLastNameAndAge: otherPerson

Stephen>    ^(self lastName = otherPerson lastName) ifTrue: [
Stephen>       self age <= otherPerson age
Stephen>    ] ifFalse: [
Stephen>       self lastName < otherPerson lastName
Stephen>    ]

Stephen> ...and the sort block would be:

Stephen>    [ :a :b | a preceedsByLastNameAndAge: otherPerson ]

Stephen> - Stephen

Although so as not to freak out the English Majors, you'd
probably spell precedes correctly. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!





More information about the Squeak-dev mailing list