Has someone ever built a "sort block generator"
Hi guys, Currently I have some sorting blocks which support "nil" elements (making them go first). So here is a general nil tolerant sort block based on one field: defaultNilTolerantSortBlock: aBlock [ :a :b | a ifNil: [ true ] ifNotNil: [ b ifNil: [ false ] ifNotNil: [ aBlock value: a value: b ] ] ] Now...imagine that now I want to first on element1, then over element2...and both could be nil...in which case should go "first". Anyway...does someone ever built some tool where you pass an ordered set of closures and it builds the super ugly resulting sort block? Cheers, -- Mariano http://marianopeck.wordpress.com
Hi mariano what are you doing? because it looks strange to need a sort block generator :). Why cann't filter all the objects that have either fields to nil first? Stef On 31/7/14 19:40, Mariano Martinez Peck wrote:
Hi guys,
Currently I have some sorting blocks which support "nil" elements (making them go first). So here is a general nil tolerant sort block based on one field:
defaultNilTolerantSortBlock: aBlock [ :a :b | a ifNil: [ true ] ifNotNil: [ b ifNil: [ false ] ifNotNil: [ aBlock value: a value: b ] ] ]
Now...imagine that now I want to first on element1, then over element2...and both could be nil...in which case should go "first".
Anyway...does someone ever built some tool where you pass an ordered set of closures and it builds the super ugly resulting sort block?
Cheers,
-- Mariano http://marianopeck.wordpress.com
On Thu, Jul 31, 2014 at 10:50 PM, stepharo <stepharo@free.fr> wrote:
what are you doing?
I think Mariano would like something like this: persons sorted: #(lastname firstname birthdate) asSortBlock that would sort by lastname, and if lastnames are equal by firstnames and if both lastnames and firstnames are equal by birthdate. -- Damien Cassou http://damiencassou.seasidehosting.st "Success is the ability to go from one failure to another without losing enthusiasm." Winston Churchill
Y asked for the same thing a few days ago in http://forum.world.st/Multiple-sorting-helper-td4770613.html Something like: sorter := MultipleSortCriteria new add: #lastName; add: [:each | each personalInfo age ] ascending: false. aCollection asSortedCollection: sorter. you could add something like: sorter := MultipleSortCriteria new add: #lastName; add: #firstName ascending: false nullsFirst: true. aCollection asSortedCollection: sorter. Regards! Esteban A. Maringolo 2014-08-01 2:40 GMT-03:00 Damien Cassou <damien.cassou@gmail.com>:
On Thu, Jul 31, 2014 at 10:50 PM, stepharo <stepharo@free.fr> wrote:
what are you doing?
I think Mariano would like something like this:
persons sorted: #(lastname firstname birthdate) asSortBlock
that would sort by lastname, and if lastnames are equal by firstnames and if both lastnames and firstnames are equal by birthdate.
-- Damien Cassou http://damiencassou.seasidehosting.st
"Success is the ability to go from one failure to another without losing enthusiasm." Winston Churchill
On Fri, Aug 1, 2014 at 11:31 AM, Esteban A. Maringolo <emaringolo@gmail.com> wrote:
Y asked for the same thing a few days ago in http://forum.world.st/Multiple-sorting-helper-td4770613.html
Something like: sorter := MultipleSortCriteria new add: #lastName; add: [:each | each personalInfo age ] ascending: false. aCollection asSortedCollection: sorter.
Exactly!!! And... what is most important for me, is that to the MultipleSortCriteria I would like to ask #sortBlock :) Thanks Esteban for better explaining what I was looking for ;)
you could add something like: sorter := MultipleSortCriteria new add: #lastName; add: #firstName ascending: false nullsFirst: true. aCollection asSortedCollection: sorter.
Regards!
Esteban A. Maringolo
2014-08-01 2:40 GMT-03:00 Damien Cassou <damien.cassou@gmail.com>:
On Thu, Jul 31, 2014 at 10:50 PM, stepharo <stepharo@free.fr> wrote:
what are you doing?
I think Mariano would like something like this:
persons sorted: #(lastname firstname birthdate) asSortBlock
that would sort by lastname, and if lastnames are equal by firstnames and if both lastnames and firstnames are equal by birthdate.
-- Damien Cassou http://damiencassou.seasidehosting.st
"Success is the ability to go from one failure to another without losing enthusiasm." Winston Churchill
-- Mariano http://marianopeck.wordpress.com
On 01 Aug 2014, at 4:47 , Mariano Martinez Peck <marianopeck@gmail.com> wrote:
On Fri, Aug 1, 2014 at 11:31 AM, Esteban A. Maringolo <emaringolo@gmail.com> wrote: Y asked for the same thing a few days ago in http://forum.world.st/Multiple-sorting-helper-td4770613.html
Something like: sorter := MultipleSortCriteria new add: #lastName; add: [:each | each personalInfo age ] ascending: false. aCollection asSortedCollection: sorter.
Exactly!!! And... what is most important for me, is that to the MultipleSortCriteria I would like to ask #sortBlock :)
Thanks Esteban for better explaining what I was looking for ;)
I always liked this approach: http://objology.blogspot.no/2010/11/tag-sortfunctions-redux.html Donât think anyoneâs ported it to Pharo yet though. Cheers, Henry
Grids, collections, and sorting/filtering + paging. And xls export. I guess we all have this kind of need in Seaside apps (and/or datatables). Maybe we could have a hangout about these things. I use the MagritteReport thing with some Twitter Bootstrap additions for reports. Is there any best practice article somewhere that you use as a reference for your designs? Phil On Friday, August 1, 2014, Henrik Johansen <henrik.s.johansen@veloxit.no> wrote:
On 01 Aug 2014, at 4:47 , Mariano Martinez Peck <marianopeck@gmail.com <javascript:_e(%7B%7D,'cvml','marianopeck@gmail.com');>> wrote:
On Fri, Aug 1, 2014 at 11:31 AM, Esteban A. Maringolo < emaringolo@gmail.com <javascript:_e(%7B%7D,'cvml','emaringolo@gmail.com');>> wrote:
Y asked for the same thing a few days ago in http://forum.world.st/Multiple-sorting-helper-td4770613.html
Something like: sorter := MultipleSortCriteria new add: #lastName; add: [:each | each personalInfo age ] ascending: false. aCollection asSortedCollection: sorter.
Exactly!!! And... what is most important for me, is that to the MultipleSortCriteria I would like to ask #sortBlock :)
Thanks Esteban for better explaining what I was looking for ;)
I always liked this approach: http://objology.blogspot.no/2010/11/tag-sortfunctions-redux.html
Donât think anyoneâs ported it to Pharo yet though.
Cheers, Henry
-- --- Philippe Back Visible Performance Improvements Mob: +32(0) 478 650 140 | Fax: +32 (0) 70 408 027 Mail:phil@highoctane.be | Web: http://philippeback.eu Blog: http://philippeback.be | Twitter: @philippeback Youtube: http://www.youtube.com/user/philippeback/videos High Octane SPRL rue cour Boisacq 101 | 1301 Bierges | Belgium Pharo Consortium Member - http://consortium.pharo.org/ Featured on the Software Process and Measurement Cast - http://spamcast.libsyn.com Sparx Systems Enterprise Architect and Ability Engineering EADocX Value Added Reseller
On 1 août 2014, at 16:50, Henrik Johansen <henrik.s.johansen@veloxit.no> wrote:
On 01 Aug 2014, at 4:47 , Mariano Martinez Peck <marianopeck@gmail.com> wrote:
On Fri, Aug 1, 2014 at 11:31 AM, Esteban A. Maringolo <emaringolo@gmail.com> wrote: Y asked for the same thing a few days ago in http://forum.world.st/Multiple-sorting-helper-td4770613.html
Something like: sorter := MultipleSortCriteria new add: #lastName; add: [:each | each personalInfo age ] ascending: false. aCollection asSortedCollection: sorter.
Exactly!!! And... what is most important for me, is that to the MultipleSortCriteria I would like to ask #sortBlock :)
Thanks Esteban for better explaining what I was looking for ;)
I always liked this approach: http://objology.blogspot.no/2010/11/tag-sortfunctions-redux.html
Donât think anyoneâs ported it to Pharo yet though.
Yes it looks cool! We can try to port it then
Cheers, Henry
2014-08-01 16:50 GMT+02:00 Henrik Johansen <henrik.s.johansen@veloxit.no>:
On 01 Aug 2014, at 4:47 , Mariano Martinez Peck <marianopeck@gmail.com> wrote:
On Fri, Aug 1, 2014 at 11:31 AM, Esteban A. Maringolo < emaringolo@gmail.com> wrote:
Y asked for the same thing a few days ago in http://forum.world.st/Multiple-sorting-helper-td4770613.html
Something like: sorter := MultipleSortCriteria new add: #lastName; add: [:each | each personalInfo age ] ascending: false. aCollection asSortedCollection: sorter.
Exactly!!! And... what is most important for me, is that to the MultipleSortCriteria I would like to ask #sortBlock :)
Thanks Esteban for better explaining what I was looking for ;)
I always liked this approach: http://objology.blogspot.no/2010/11/tag-sortfunctions-redux.html
Donât think anyoneâs ported it to Pharo yet though.
Cheers, Henry
+1 Note that I have a public experimental port to Pharo in SmalltalkHub that I already announced once (in http://smalltalkhub.com/#!/~nice/NiceVMExperiments <http://smalltalkhub.com/#%21/%7Enice/NiceVMExperiments/versions/VMMaker.osco...> but I can't tell exactly the package name TagSortFunction or something like that, the web interface of SmalltalkHub is currently showing me a debugger with nil does not understand #data). Yes, I know VM-experiments is not the right place for such package, but at the time I didn't find where to create a new project... Since I got absolutely zero feedback after a long thread, I assumed it was not interesting anybody... But my personal opinion differs: this should be included in each and every Smalltalk.
On Aug 1, 2014, at 10:50 AM, Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com> wrote:
2014-08-01 16:50 GMT+02:00 Henrik Johansen <henrik.s.johansen@veloxit.no>:
On 01 Aug 2014, at 4:47 , Mariano Martinez Peck <marianopeck@gmail.com> wrote:
On Fri, Aug 1, 2014 at 11:31 AM, Esteban A. Maringolo <emaringolo@gmail.com> wrote:
Y asked for the same thing a few days ago in http://forum.world.st/Multiple-sorting-helper-td4770613.html
Something like: sorter := MultipleSortCriteria new add: #lastName; add: [:each | each personalInfo age ] ascending: false. aCollection asSortedCollection: sorter.
Exactly!!! And... what is most important for me, is that to the MultipleSortCriteria I would like to ask #sortBlock :)
Thanks Esteban for better explaining what I was looking for ;)
I always liked this approach: http://objology.blogspot.no/2010/11/tag-sortfunctions-redux.html
Donât think anyoneâs ported it to Pharo yet though.
Cheers, Henry
+1
Note that I have a public experimental port to Pharo in SmalltalkHub that I already announced once (in http://smalltalkhub.com/#!/~nice/NiceVMExperiments but I can't tell exactly the package name TagSortFunction or something like that, the web interface of SmalltalkHub is currently showing me a debugger with nil does not understand #data). Yes, I know VM-experiments is not the right place for such package, but at the time I didn't find where to create a new project...
Since I got absolutely zero feedback after a long thread, I assumed it was not interesting anybody... But my personal opinion differs: this should be included in each and every Smalltalk.
+1 Aloha
Nicolas: 2014-08-01 17:50 GMT-03:00 Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com>:
http://objology.blogspot.no/2010/11/tag-sortfunctions-redux.html
Donât think anyoneâs ported it to Pharo yet though. +1
Note that I have a public experimental port to Pharo in SmalltalkHub that I already announced once (in http://smalltalkhub.com/#!/~nice/NiceVMExperiments but I can't tell exactly the package name TagSortFunction or something like that, the web interface of SmalltalkHub is currently showing me a debugger with nil does not understand #data). Yes, I know VM-experiments is not the right place for such package, but at the time I didn't find where to create a new project...
I decided to embrace you initial port and also made some enhancements to TAGSortFunctions. I added the current features: * Support of MAElementDescription conversion to SortFunction (in addition to block and unary symbol support) * Collation of nil elements, deciding whether to put nil at the end or beginning of the result. (similar to the ORDER BY column [NULLS FIRST|LAST] semantics of SQL). Unit tests for the above described features. All the added features preserve the original behavior of the sort functions, so nil collation must be "enabled" explicitly by sending #undefinedFirst/#undefinedLast to the sort function, otherwise it will fail if you attempt to compare an object with nil. I would like to move this to a specific repository in STHub with its own Metacello config (Magritte support is packaged separately). Do you agree with this? Regards! Esteban A. Maringolo
Am 01.08.2014 um 16:50 schrieb Henrik Johansen <henrik.s.johansen@veloxit.no>:
On 01 Aug 2014, at 4:47 , Mariano Martinez Peck <marianopeck@gmail.com> wrote:
On Fri, Aug 1, 2014 at 11:31 AM, Esteban A. Maringolo <emaringolo@gmail.com> wrote: Y asked for the same thing a few days ago in http://forum.world.st/Multiple-sorting-helper-td4770613.html
Something like: sorter := MultipleSortCriteria new add: #lastName; add: [:each | each personalInfo age ] ascending: false. aCollection asSortedCollection: sorter.
Exactly!!! And... what is most important for me, is that to the MultipleSortCriteria I would like to ask #sortBlock :)
Thanks Esteban for better explaining what I was looking for ;)
I always liked this approach: http://objology.blogspot.no/2010/11/tag-sortfunctions-redux.html
+1 Norbert
Donât think anyoneâs ported it to Pharo yet though.
Cheers, Henry
On 1 août 2014, at 16:47, Mariano Martinez Peck <marianopeck@gmail.com> wrote:
On Fri, Aug 1, 2014 at 11:31 AM, Esteban A. Maringolo <emaringolo@gmail.com> wrote: Y asked for the same thing a few days ago in http://forum.world.st/Multiple-sorting-helper-td4770613.html
Something like: sorter := MultipleSortCriteria new add: #lastName; add: [:each | each personalInfo age ] ascending: false. aCollection asSortedCollection: sorter.
Exactly!!! And... what is most important for me, is that to the MultipleSortCriteria I would like to ask #sortBlock :)
To sort a collection with such an object it only has to answer #value:value:, so is there a special reason you want to generate a block from it? Because generating such blocks might be a bit cumbersome and the object already does the job, no?
Thanks Esteban for better explaining what I was looking for ;)
you could add something like: sorter := MultipleSortCriteria new add: #lastName; add: #firstName ascending: false nullsFirst: true. aCollection asSortedCollection: sorter.
Regards!
Esteban A. Maringolo
2014-08-01 2:40 GMT-03:00 Damien Cassou <damien.cassou@gmail.com>:
On Thu, Jul 31, 2014 at 10:50 PM, stepharo <stepharo@free.fr> wrote:
what are you doing?
I think Mariano would like something like this:
persons sorted: #(lastname firstname birthdate) asSortBlock
that would sort by lastname, and if lastnames are equal by firstnames and if both lastnames and firstnames are equal by birthdate.
-- Damien Cassou http://damiencassou.seasidehosting.st
"Success is the ability to go from one failure to another without losing enthusiasm." Winston Churchill
-- Mariano http://marianopeck.wordpress.com
participants (10)
-
Camille Teruel -
Damien Cassou -
Eliot Miranda -
Esteban A. Maringolo -
Henrik Johansen -
Mariano Martinez Peck -
Nicolas Cellier -
Norbert Hartl -
phil@highoctane.be -
stepharo