Datagrid sorting

Andre.Bisseret Andre.Bisseret at inria.fr
Mon Apr 26 09:13:16 EDT 2010


Bonjour Marcello,


Le 26 avr. 10 à 13:15, Marcello Bertoli a écrit :

> On 23/apr/2010, at 21.46, Andre.Bisseret wrote:
>
>> Actually, to do a multi-criteria sorting (here two criteria) one  
>> must sort firstly by the second criteria, then by the first one. So  
>> that one gets the names in alphabetical order inside each date. So  
>> a mixt of my two proposal seems to do the trick ( In fact it  
>> suffices to inverse the order of the two "dispatch" lines in the  
>> last script I send you (as they were in the first proposal);
>
> Thanks Andre,
It my pleasure; I like looking for solution to such problems ;-))
>
> your code seems to do the trick! I tried also with 3 criteria.
Yes possible with any number of criteria (the trick is to sort them in  
the reverse order (n first, then n-1, n-2 etc. either manually or by  
script)
>
>
>> [...]
>>     if theColumn is "date" then
>>        dispatch "sortByColumn" to the target with "name" ## second  
>> criterium
>>        --wait 1 sec
>>        dispatch "sortByColumn" to the target with "date" ## first  
>> criterium
>>     end if
>>  end if
>> end mouseDown
>
>
> Actually I don't understand one thing: the "wait 1 second"  
> statement. If I leave this statement commented the code doesn't  
> work. If I activate it, everythings works... Can you explain me what  
> the wait does in this particular scenario?

In my first trials, I put a wait (3 seconds) just to see the  
intermediate state.
But when I tried without the wait, that did not work anymore.
Then, I supposed that the second dispatch was sent before the first  
sortByColumn be finished. Then the idea that the wait was necessary.

A while later, trying to comment it, I discovered that it was working  
without any wait as well!!!
I must confess that I am unable to explain why.

I just tried again here, and I may confirm that the verily same script  
works when the wait line is commented!! a mystery for me ;-))  
(fortunately, I kept this line when posting, so that you get the idea  
to uncomment it ;-))

I must add that the data grid I am using for trials has only 9 rows (3  
dates with 3 names each)! could be the wait is necessary with much  
more rows(?)

As it is working for me with or without "wait", I can't test; but you  
might try a far less long delay in the wait to get it unnoticeable!:  
something like "wait 1" (means 1 tick). Seems I have read somewhere  
that even "wait 0" could works as it forces the two commands to be  
strickly successive.

I don't really master this use of wait (or send in time)! Might be  
somebody in the list wil give us some better explanation

Best regards from Grenoble

André






More information about the use-livecode mailing list