keeping keys of an array in the order they came in?
jonathandlynch at gmail.com
jonathandlynch at gmail.com
Sat Aug 19 08:22:08 EDT 2017
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.
Sent from my iPhone
> On Aug 19, 2017, at 8:12 AM, jbv via use-livecode <use-livecode at lists.runrev.com> 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
>
> You can also use a two-dimentional array instead
> of 2 separate arrays...
>
> jbv
>
>
>> On Sat, August 19, 2017 1:33 pm, Klaus major-k via use-livecode wrote:
>> Hi dfriends,
>>
>>
>> need a little help, I am filling an array (to eliminate doublettes) and
>> really need to keep the order of the keys as they came in.
>>
>> Example:
>> ...
>> put "60,30,40" into tK repeat for each item tItem in tK put "sdsdsdsddsd"
>> into tArray[tItem] end repeat put the keys of tArray ...
>> Now I would like to get:
>> 60
>> 30
>> 40
>>
>>
>> This is just an example, I cannot control the content of tK.
>> Know what I mean?
>>
>>
>> Any hints very welcome, thank you!
>>
>>
>>
>> Best
>>
>>
>> Klaus
>>
>>
>> --
>> Klaus Major
>> http://www.major-k.de
>> klaus at major-k.de
>>
>>
>> _______________________________________________
>> use-livecode mailing list use-livecode at lists.runrev.com Please visit this
>> url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>>
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list