2009/12/23 Levente Uzonyi <leves@elte.hu>:
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).
The only case should be to keep collection automatically sorted when its contents further evolves... Of course, using repeated #add: is inefficient (#addAll: has a rule for sorting once or at every #add:).
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).
Don't open a new issue. There is http://code.google.com/p/pharo/issues/detail?id=1214 http://code.google.com/p/pharo/issues/detail?id=1346 Nicolas
Levente
Stef _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project