On 04.02.2015, at 19:22, Raymond Asselin <jgr.asse...@me.com> 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
Beginners@lists.squeakfoundation.org
http://lists.squeakfoundation.org/mailman/listinfo/beginners

Reply via email to