Hi All and Especially Joachim,
-- I have finally gotten around to publishing my DynamicSortBlock on VAST Goodies in KscDynamicSortBlock. I have enhanced it slightly to allow the #directions collection to be specified by symbols as well as booleans. See below. Also, look at the class comment and the comment in the #value:value: method. Those of us who need to sort database rows that don't have methods defined to access the columns should note the ability use the column name that can be accessed via the #at: message (see the #value:value: method). Joachim - how did DynamicSortBlock workout for you? DynamicSortBlock instances are used as the sortBlock of a SortedCollection to simplify sorting complex classes. They can also be sent to the #sort: method of other collections like arrays and ordered collections. It is not in the block family of classes but acts like one by answering the #value:value: message with a boolean like a sort block would. It is used by supplying collections of accessors and corresponding directions. Errors accessing values by the accessors are trapped and an attempt is made to get a value via #at:. This is to accommodate sorting database rows and other records that respond to #at:. The direction can now be specified as a boolean or a string/symbol. #(true false #ascending #descending 'ascending' 'descending' #garbage) that will result in: an OrderedCollection(true false true false true false true). Direction defaults to ascending, so if values are anything other than true, false or a string starting with a 'd' or 'D', ascending is assumed. To sort objects with three ascending accessors: SortedCollection sortBlock: (DynamicSortBlock accessors: #(#a1 #a2 #a3). To sort objects with four accessors (ascending descending ascending descending): SortedCollection sortBlock: (DynamicSortBlock accessors: #(#a1 #a2 #a3 #a4) directions: #(true false #asc #desc). or SortedCollection sortBlock: (DynamicSortBlock sortCriteria: (OrderedCollection with: #a1->true with: #a2->false with: #a3->#asc with: #a4->#desc)). The use of symbols allows for more understandable code. One wouldn't normally mix booleans and symbols. You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Thanks, Lou, for publishing your code.
-- Since we're approaching the end of the year, I am in the middle of upgrading all the tax-related functionalities of Kontolino.de, so the feature I was planning to use it for will have to wait a little. But it is on the list.... Joachim Am Montag, 17. November 2014 21:13:42 UTC+1 schrieb Louis LaBrunda:
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email]. To post to this group, send email to [hidden email]. Visit this group at http://groups.google.com/group/va-smalltalk. For more options, visit https://groups.google.com/d/optout. |
Free forum by Nabble | Edit this page |