[Newbies] Re: How to doubble sort a collection
pdebruic at gmail.com
Wed Feb 4 18:33:25 UTC 2015
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.
Raymond Asselin-4 wrote
> For now I implemented:
> ^notes sort:[:a :b | (a date = b date) and:[a temps > b temps]] .
> ^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 <
> > a écrit :
>> a date = b date
>> ifTrue:[a temps > b temps]
>> ifFalse:[a date > b date]
> Beginners mailing list
> Beginners at .squeakfoundation
View this message in context: http://forum.world.st/How-to-doubble-sort-a-collection-tp4803657p4803711.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.
More information about the Beginners