On Wed, 23 Dec 2009, Stéphane Ducasse wrote:
What bugs me is that #sortBy: does not what it says. I would expect that
aCollection sortBy: [ :each | each name ]
does the same as
aCollection sort: [ :a :b | a name <= b name ]
if you want that, I can provide a fast implementation of #sortBy:
Not all collections are sortable and #sort: is sorting in-place, so it's hardly
doable.
But it would be nice to have sort: and sortBlock: polymorph.
Because right now we cannot have OrderedCollection and Array or
SortedCollection interchanged.
SortedCollection should be used as rarely as possible. In the past it was
used for sorting which is a misuse of this data structure (I wonder why
such data strucure exists at all, it's almost never useful).
If you pick the changes from squeak trunk, Array and OrderedCollection
(and SortedCollection) will understand #sort and #sort: and will have the same
semantics: sort in place (by a stable sorting algorithm).
Levente
Stef
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project