I have this kind of sorting on anOrderedCollection
BlocNotes >>sortedNotes ^notes sorted:[:a :b | a date > b date] This sort my notes on date but I want them sort by date AND inside a date by hours and I don't khow how to do this. Some insights? aNote = 'med com date temps' instancesVariables what I call hours = temps witch is a number like 2123 for 21h23 Some insights?_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Hi Raymond,
Try: ^notes sorted:[:a :b | (a date > b date) | ((a date = b date) & (a date temps > b date temps))]. Lou On Wed, 04 Feb 2015 10:34:48 -0500, Raymond Asselin <[hidden email]> wrote: >I have this kind of sorting on anOrderedCollection > >BlocNotes >>sortedNotes > ^notes sorted:[:a :b | a date > b date] > >This sort my notes on date but I want them sort by date AND inside a date by hours and I don't khow how to do this. > >Some insights? > >aNote = 'med com date temps' instancesVariables what I call hours = temps witch is a number like 2123 for 21h23 > >Some insights? Louis LaBrunda Keystone Software Corp. SkypeMe callto://PhotonDemon mailto:[hidden email] http://www.Keystone-Software.com _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Does using the | or & notation have any advantages over and: or or: or ifTrue:ifFalse ?
I always write expressions like the one you've written like: a date = b date ifTrue:[a temps > b temps] ifFalse:[a date > b date]
|
| and & make sure that each expression between them is executed - so it will do each of: a date > b date and a date = b date and a date > temps > b date temps This matters if one of these is significantly slower than the others - it will run it even it it doesn't need too. Also if any side-effects are in one of these expressions, this will make that side effect happen (there aren't any in these, though). and: and or: stop executing as soon as one of them is satisfied sufficiently - so if a date > b date then it will immediately return true without bothering with the rest of the expressions. ifTrue:ifFalse: is similar - except you will evaluate the condition expression AND one of the following expressions. Often this doesn't matter one way or another - but when it does, it matters a lot. -cbc On Wed, Feb 4, 2015 at 9:00 AM, Paul DeBruicker <[hidden email]> wrote: Does using the | or & notation have any advantages over and: or or: or _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Paul DeBruicker
begin 644 DynamicSort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EG;F%L(&5X:717:71H.B`H:71E;4(@870Z(&%C8V5S<V]R*5TN#0H) M"2AV86QU94$@/2!V86QU94(I(&EF1F%L<V4Z(%L-"@D)"79A;'5E02!I<TYI M;"!I9E1R=64Z(%M>9&ER96-T:6]N72X-"@D)"79A;'5E0B!I<TYI;"!I9E1R M=64Z(%M>9&ER96-T:6]N(&YO=%TN#0H)"0DH=F%L=65!(#P@=F%L=65"*2!I M9E1R=64Z(%M>9&ER96-T:6]N72X-"@D)"2AV86QU94$@/B!V86QU94(I(&EF M5')U93H@6UYD:7)E8W1I;VX@;F]T72X-"@D)72X-"@E=+@T*"5YT<G5E+@T* L(2`A#0H-"D1Y;F%M:6-3;W)T0FQO8VL@:6YI=&EA;&EZ94%F=&5R3&]A9"$* ` end _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Paul DeBruicker
On Wed, 4 Feb 2015 09:00:13 -0800 (PST), Paul DeBruicker
<[hidden email]> wrote: >Does using the | or & notation have any advantages over and: or or: or >ifTrue:ifFalse ? and: and or: are needed when you don't want to execute the code inside the block unless it is needed. They are also used to protect from executing code that shouldn't be run for example: x notNil and: [x foo > y foo] >I always write expressions like the one you've written like: >a date = b date > ifTrue:[a temps > b temps] > ifFalse:[a date > b date] I like this but it may be a little tricky for a beginner. But both or replay help one to learn. I have also attached a file out (from VA Smalltalk) of a class that acts like a sort block but is much easier to use for complex sorts. Lou >Louis LaBrunda wrote >> Hi Raymond, >> >> Try: >> >> ^notes sorted:[:a :b | (a date > b date) | ((a date = b date) & (a date >> temps > b date temps))]. >> >> Lou >> >> On Wed, 04 Feb 2015 10:34:48 -0500, Raymond Asselin < > >> jgr.asselin@ > >> > >> wrote: >> >>>I have this kind of sorting on anOrderedCollection >>> >>>BlocNotes >>sortedNotes >>> ^notes sorted:[:a :b | a date > b date] >>> >>>This sort my notes on date but I want them sort by date AND inside a date >by hours and I don't khow how to do this. >>> >>>Some insights? >>> >>>aNote = 'med com date temps' instancesVariables what I call hours = temps >witch is a number like 2123 for 21h23 >>> >>>Some insights? >> ----------------------------------------------------------- >> Louis LaBrunda >> Keystone Software Corp. >> SkypeMe callto://PhotonDemon >> mailto: > >> Lou@ > >> http://www.Keystone-Software.com >> >> _______________________________________________ >> Beginners mailing list > >> Beginners@.squeakfoundation > >> http://lists.squeakfoundation.org/mailman/listinfo/beginners Louis LaBrunda Keystone Software Corp. SkypeMe callto://PhotonDemon mailto:[hidden email] http://www.Keystone-Software.com _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Paul DeBruicker
For now I implemented:
sortedNotes ^notes sort:[:a :b | (a date = b date) and:[a temps > b temps]] . AND notesSorted ^notes sort:[:a :b | a date = b date ifTrue:[a temps > b temps] ifFalse:[a date > b date]] . does exactly the same result. But there is still notes in a same date that do not sort correctly, the begining is good and after 5 or so objects I get some witch do not seem to be sorted. BTW don't know the difference between sort: and sorted: it seems as if the last one produce a new collection and the first one produce same collection but sorted. Note: I use 24 hours instead of a.m. / p.m. is this may cause problems? > Le 2015-02-04 à 12:00, Paul DeBruicker <[hidden email]> a écrit : > > a date = b date > ifTrue:[a temps > b temps] > ifFalse:[a date > b date] _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
On 04.02.2015, at 19:22, Raymond Asselin <[hidden email]> wrote: > For now I implemented: > > sortedNotes > ^notes sort:[:a :b | (a date = b date) and:[a temps > b temps]] . > > AND > > notesSorted > ^notes sort:[:a :b | a date = b date > ifTrue:[a temps > b temps] > ifFalse:[a date > b date]] . > > does exactly the same result. sounds strange. Probably you don't want to store date and time separated but as DateAndTime instances, then you just have to sort them by that. Look at that class. Also, you can see that Date is a subclass of Timespan, which implies a duration: a Date is a timespan of one day. You probably don't want that if you compare them like above. > > But there is still notes in a same date that do not sort correctly, the begining is good and after 5 or so objects > I get some witch do not seem to be sorted. can you give an example? > > BTW don't know the difference between sort: and sorted: > it seems as if the last one produce a new collection and the first one produce same collection but sorted. > exactly. #sorted: is like saying “Give me this, but sorted” and this “give me” typically results in a new collection. #sort: is like saying “You! Sort yourself!” and implies mutation (a bit like set! in scheme or sort! in ruby) > Note: I use 24 hours instead of a.m. / p.m. is this may cause problems? see above BEst -Tobias_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Raymond Asselin-4
Proably because you're using #> and not #>=. If not that post the list of dates/times that don't sort properly.
also - #sort: & #sort sort in place. #sorted & sorted: make a new copy as you've seen. If your objects should always sort the same way just implement #<= in the instance side of your object and then you can use #sort or #sorted without having to add a sort block.
|
In reply to this post by Tobias Pape
Le 2015-02-04 à 13:33, Tobias Pape <[hidden email]> a écrit : _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Raymond Asselin-4
You have a logic issue with the first one: sortedNotes ^notes sort:[:a :b | (a date = b date) and:[a temps > b temps]] . This is saying that the the two dates are different, then false. For this you probably want to be something like: sortedNotes ^notes sort:[:a :b | a date > b date or: [(a date = b date) and:[a temps > b temps]]] . -cbc On Wed, Feb 4, 2015 at 10:22 AM, Raymond Asselin <[hidden email]> wrote: For now I implemented: _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Raymond Asselin-4
Are your temps stored as strings? Strings that are numbers aren't coerced to numbers before comparison.
e.g. in a workspace '765' > '1230' prints true and 765 > 1230 prints false.....
|
In reply to this post by cbc
I finaly found the problem witch was not in the code suggest but behind the keyboard.
In fact when the time is generated everything is good , when i entered it by hand = this is a String. So I had in the sorting code:
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Thank to everybody because I learned a lot here
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Raymond Asselin <jgr.asselin <at> me.com> writes:
> > Thank to everybody because I learned a lot here > If you're in a recent Squeak, then you can also write: ^notes sorted: #date descending , #temps descending _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by Raymond Asselin-4
Hi Raymond, On Wed, Feb 4, 2015 at 12:42 PM, Raymond Asselin <[hidden email]> wrote: Whoa! That looks familiar! :) With Maui, you normallly don't need to do methods like #sortedNotes. You can just have #notes in there like you do at the bottom (set its output resultView to #panel). Then if you simply implement these methods on your Note class: mauiDefaultColumns ^ #(med date heures com) and mauiSortableColumns ^ #(med date heures comString) and comString ^ self com ifNil: [ String empty ] Then, hover your mouse inside the yellowish area of the collection, press ESC to invoke the menu, then select "generate heading". You will get proper headers for those columns with ascending / descending sort arrows for each column. All for free from Maui. HTH. _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
I Got it. You talked about generate heading in the past but can't figure how to send it. Now it's clear "<<hover your mouse inside the yellowish area of the collection, press ESC to invoke the menu, then select "generate heading">>. Envoyé de mon iPhone
_______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
On Mon, Feb 16, 2015 at 5:21 PM, Raymond Asselin <[hidden email]> wrote:
> I Got it. > You talked about generate heading in the past but can't figure how to send > it. > Now it's clear "<<hover your mouse inside the yellowish area of the > collection, press ESC to invoke the menu, then select "generate heading">>. Ah, sorry I did not make that more clear! Yes, that is the collection-object itself is represented on the screen, with its own context menu. And, you can actually do a poor-mans multi-level sorting by selecting the ascending / descending arrows in \reverse\ order (inner-most sort level to outer-most). > Envoyé de mon iPhone > > Le 2015-02-16 à 16:36, Chris Muller <[hidden email]> a écrit : > > Hi Raymond, > > On Wed, Feb 4, 2015 at 12:42 PM, Raymond Asselin <[hidden email]> wrote: >> >> <SortedNotesExample.png> >> >> > > Whoa! That looks familiar! :) > > With Maui, you normallly don't need to do methods like #sortedNotes. You > can just have #notes in there like you do at the bottom (set its output > resultView to #panel). Then if you simply implement these methods on your > Note class: > > mauiDefaultColumns > ^ #(med date heures com) > > and > > mauiSortableColumns > ^ #(med date heures comString) > > and > > comString > ^ self com ifNil: [ String empty ] > > Then, hover your mouse inside the yellowish area of the collection, press > ESC to invoke the menu, then select "generate heading". > > You will get proper headers for those columns with ascending / descending > sort arrows for each column. All for free from Maui. > > HTH. > > _______________________________________________ > Beginners mailing list > [hidden email] > http://lists.squeakfoundation.org/mailman/listinfo/beginners > > > _______________________________________________ > Beginners mailing list > [hidden email] > http://lists.squeakfoundation.org/mailman/listinfo/beginners > Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |