Nicolas Cellier wrote: >>> >> I'd like a selector that I can apply to any collection like a Set too. >> For example, in some implementations keys are a Set (original st80) in >> others keys are an Array (Squeak trunk/Pharo). >> So, in order to have more portable pieces of code I ended up with >> (self keys asArray sort). >> Maybe the most simple thing would be to define >> Collection>>sort >> ^self asArray sort > > Arg, I pressed tab, then (oops) space and sent the message too soon... > I wanted to add this comment: > "Sort the collection in place if possible, otherwise answer a sorted > Array. > Subclasses that can sort in place should override this message." >
Interesting. Possibly good. But what would you do when you knew you wanted a *copy* that was sorted? "myCollection copy sort" would work, but might or might not create two copies, depending on whether the original class was one that could be sorted in place. I'm now leaning toward defining #copySorted or some such on Collection for this purpose. And *maybe* also doing what you propose with #sort. Regards, -Martin _______________________________________________ Pharo-project mailing list [email protected] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
