Simple array question

Alex Tweedly alex at tweedly.net
Thu Sep 30 20:48:38 EDT 2004


At 15:50 30/09/2004 -0700, Mark Brownell wrote:
>On Thursday, September 30, 2004, at 02:48 PM, Jim Hurley wrote:
>
>>  repeat with i = 1 to m
>>     put x[i] into line i of tResults
>>  end repeat
>>  put tResults into field 2

takes 170 ticks for 11,000 elements on my slow machine

>>But is there any quick way to get the list sorted by the keys? I have 
>>11,000 elements in the array.

>>Maybe by using a faster repeat loop and a simpler append technique.
>
>put "" into tResults
>put 1 into i
>repeat
>     put x[i] & return after tResults
>     if x[i] = empty then exit repeat
>     add 1 to i
>  end repeat
>  put tResults into field 2
>
>This is not sorting, I guess.

Takes 25 ticks - much better.

But there's no reason not to use a loop counter - that should be faster 
than an explicit increment and test for empty.
   repeat with i = 1 to m
     put x[i] & return after tResults
   end repeat
   put tResults into field 2

takes only 15 ticks for 11,000 elements.

-- Alex.


More information about the use-livecode mailing list