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

Klaus major-k klaus at
Sat Aug 19 08:28:02 EDT 2017

Hi Jonathan,

> Am 19.08.2017 um 14:22 schrieb Jonathan Lynch via use-livecode <use-livecode at>:
> You could alter the name of the elements...
> Put "X_" & tK into tArrayElement
> Put tData into myArray[tArrayElement]
> X would be created in a counting loop.
> That way, when you get the keys of the array, you can sort numeric by item 1 of each, using "_" as the itemdel. This will give you the original order with just 1 array dimension, and you can easily retrieve the value of tK.

not possible, I am doing something like this:
put empty into tArray
repeat for each line tLine in tData
put item 2 of tLine into tKey
if tKey = EMPTY then next repeat
put tLine & CR after tArray[tKey]
end repeat
And item 2 are these said number, so I cannot control/name the key this way.

> Sent from my iPhone
>> On Aug 19, 2017, at 8:12 AM, jbv via use-livecode <use-livecode at> wrote:
>> Hi Klaus
>> I've been there and the only solution I found was to maintain
>> a second array :
>> put 0 into x
>> put "abc" into array1[60]
>> add 1 to x
>> put 60 into array2[x]
>> put "xyz" into array1[30]
>> add 1 to x
>> put 30 into array2[x]
>> put the keys of array2 into tkeys
>> sort lines of tkeys ascending numeric
>> repeat for each line j in tkeys
>>   put array1[array2[j]] & return after myvar
>> end repeat



Klaus Major
klaus at

More information about the Use-livecode mailing list