Stéphane Ducasse wrote:
#sortBlock: is defined by ANSI on SortedCollection as an accessor and an instance creation method. That's what it sounds like and shouldn't be implemented on non-sorted collections.
Why? what would be the reason not to use sortBlock: for others?
The intention is different. #sortBlock: tells a collection to maintain itself as sorted even after additions and deletions. This message is not appropriate for collections that do not have that ability. #sortBlock: is not the best name for this functionality, but I think it's bad to use #sortBlock: with a different meaning.
#sorted, #sorted: -- VW already has this. VA is adding it.
What is sorted? a boolean predicate method? What a bad name. Did they forgot Kent?
An example of my previous message -- this name is confusing and should probably not be used.
Squeak/Pharo should add it, IMO, but we'll add it to Grease if not. It returns a sorted copy of SequenceableCollections and a sorted Array of all other collections.
Please not this is bogus. It does not work with certain subclasses of Sequenceable And much more important it has a bad name. Because with a nice name sortCopy then it would be much better. So with one method in VW you can get it
sortCopy ^ self sorted
+1 Regards, -Martin