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

2017-08-19 Thread Klaus major-k via use-livecode
Hi Alex, > Am 19.08.2017 um 16:57 schrieb Alex Tweedly via use-livecode > : > > 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

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

2017-08-19 Thread Alex Tweedly via use-livecode
Hmmm - you haven't mentioned how much data you're working with. Using lineoffset() to check for duplicated keys will make you (relatively) slow on large data sets, since it is O(n**2). Since you know that item 2 is not empty, you must also know that the whole line is not empty :-), so you

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

2017-08-19 Thread Klaus major-k via use-livecode
Little addition, thanks hermann: > Am 19.08.2017 um 15:44 schrieb Klaus major-k via use-livecode > : > > Hi Mike, > > I added a little IF THEN clause to avoid doublettes in the ney key, too, > and now it does what I need, thanks again! > >> Am 19.08.2017 um

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

2017-08-19 Thread Klaus major-k via use-livecode
Hi Mike, I added a little IF THEN clause to avoid doublettes in the ney key, too, and now it does what I need, thanks again! > Am 19.08.2017 um 15:12 schrieb Klaus major-k via use-livecode > : >> >> put empty into tArray >> repeat for each line tLine in tData >>

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

2017-08-19 Thread Klaus major-k via use-livecode
Hi Mike, > Am 19.08.2017 um 14:36 schrieb Mike Bonner via use-livecode > : > > Have a separate list, or a special key that holds your list of keys. > > put empty into tArray > repeat for each line tLine in tData > put item 2 of tLine into tKey > if tKey = EMPTY

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

2017-08-19 Thread Mike Bonner via use-livecode
Have a separate list, or a special key that holds your list of keys. 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] put tKey & cr after tarray['myKeyList'] end repeat Then when you need to

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

2017-08-19 Thread Klaus major-k via use-livecode
Hi Jonathan, > Am 19.08.2017 um 14:22 schrieb Jonathan Lynch via use-livecode > : > > 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,

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

2017-08-19 Thread Jonathan Lynch via use-livecode
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

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

2017-08-19 Thread jbv via use-livecode
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

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

2017-08-19 Thread Jonathan Lynch via use-livecode
Maybe a two-part array? Myarray[1,tk] You can control the first part of the array, keeping it in order, and thus not depend on how LC orders the tK part of the array. Sent from my iPhone > On Aug 19, 2017, at 7:33 AM, Klaus major-k via use-livecode > wrote: >

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

2017-08-19 Thread Klaus major-k via use-livecode
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