keeping keys of an array in the order they came in?

Klaus major-k klaus at
Sat Aug 19 11:04:19 EDT 2017

Hi Alex,

> Am 19.08.2017 um 16:57 schrieb Alex Tweedly via use-livecode <use-livecode at>:
> Hmmm - you haven't mentioned how much data you're working with.

not sure, but definitively less than 5000.

> Using lineoffset() to check for duplicated keys will make you (relatively) slow on large data sets, since it is O(n**2).

I made little test and it is fast enough for my purpose. :-)

> Since you know that item 2 is not empty, you must also know that the whole line is not empty :-),
> so you can simply check for that.
> put empty into Array
> repeat for each line tLine in tData
>  put item 2 of tLine into tKey
>  if tKey = EMPTY then next repeat
> # if tArray[tKey] is EMPTY then
>     put tLine & CR after tArray[tKey]   -- or would 'into' be even faster than 'after' ??

## I need AFTER, since I want to collect all lines with the same item 2 in that key.
## So no need for this IF clause in my case.

> # end if
> end repeat
> Alex.



Klaus Major
klaus at

More information about the Use-livecode mailing list