[Pharo-project] [Seaside-dev] GROrderedCollectionTest>>#testSort

Marcus Denker marcus.denker at inria.fr
Wed Feb 17 15:27:30 EST 2010


On Feb 17, 2010, at 9:15 PM, Julian Fitzell wrote:

> On Wed, Feb 17, 2010 at 5:13 AM, Lukas Renggli <renggli at gmail.com> wrote:
>>> #sort you mean? Not yet... we either need to add it in Pharo, fix it
>>> in the one click, or add it to the Grease package.
>> 
>> OrderedCollection>>#sort and OrderedCollection>>#sort: is already part
>> of Pharo 1.1. The Seaside tests pass in Pharo 1.1.
>> 
>> I understand and I agree with Pharo not to implement #sort and #sort:
>> in SequenceableCollection, because it does not make sense for most
>> subclasses. SortedCollection, Heap and Interval are already sorted;
>> and for LinkedList sorting does not really make sense.
> 
> As Paolo points out, they are not necessarily sorted by the desired
> block. For SortedCollection, I agree the correct behaviour is to set
> the sortBlock.

This is done already in 1.1

> VW handles subclasses (like Interval) that cannot be
> sorted in place very simply: the sorter is implemented in terms of
> #at: and #at:put: and classes that cannot be modified with #at:put:
> just return an error saying that they can't be stored into. This also
> covers, for example, Arrays that are marked as immutable. There are
> many many subclasses of SequenceableCollection that do implement
> #at:put: and can be sorted properly...


Yes, and Niko therefore suggested to factor out the sorting method in a Trait  and
then import the Trait in all classes that have at: and at:put: (even LinkedList and Stack)

http://code.google.com/p/pharo/issues/detail?id=1346

	Marcus


--
Marcus Denker  -- http://www.marcusdenker.de
INRIA Lille -- Nord Europe. Team RMoD.





More information about the Pharo-dev mailing list