SortedCollection sortBlock: (DynamicSortBlock accessors: #(#a1 #a2 #a3 #a4) directions: #(true false true false).
SortBlock with: #getter1 -> 'Ascending'
with: #getter2 -> 'Dscending'
with: aTwoArgumentBlock.
The extension beyond the examples given to-date is the block argument
type. This argument type is essentially the same as a standard
sortBlock. This makes it easy to to include a comparison other than
simple getter comparisons in the sort.
Doug Swartz
Saturday, October 22, 2011, 4:20:41 AM, you wrote:
> Lou,
> this kind of sorting is needed in so many situations, and it is
> good you posted your code and discussed your idea, even (or even
> more so because) someone came up with a better way of solving it.
> Thanks for sharing your code (also to Steven).
> One additional idea for the api:
> SortedCollection sortBlock: (DynamicSortBlock accessors: #(#a1 #a2
> #a3 #a4) directions: #(true false true false).
> I somehow think that the following might work better:
> SortedCollection sortBlock: (DynamicSortBlock accessors:
> (OrderedCollection with: #a1->true with: #a2->false)).
> or even better sequences like
> DynamicSortBlock new
> ascending: #a1; "or maybe asc: for faster typing"
> descending: a2; "or desc:"
> yourself.
> to configure a DynamicSortBlock?
> which add these associations.
> Why do I think so? Because being myself I would end up with two
> different-sized collections due to my fingers typing out of sync with my brain
> And of course I hope to see the code on VASTGoodies soon
> BTW: Have you seen this:
> http://www.smalltalk.org/components/SortCriteria.html ? I like the
> name SortCriteria, but dislike that SortedCollection would still have a setter named sortBlock:
> Joachim
--
Best regards,
Douglas mailto:swartzco...@gmail.com
Does your implementation support switching between ascending/descending for one or more criteria once a collection has been sorted? I guess this is just a matter of changing a boolean and resorting the collection, right?
Thanks Lou,I'll start using it very soon now. I'll let you know if I see any problems or enhancements.
About VASTGoodies: Not sure I understand your problem. You can move the class to another application and stuff it into a config map. That should be pretty much it, no?