unconfuse the confusing.
Posted: 15 May 2019 20:48
please dont rattle on about associative arrays, which have no guaranteed ordering...
I understand the tables are presently keyed by arrival order.
I have tables ahnentafel, indiPTR, generation, their keys are obviously 1..n but the values are not in "order" (that being the order I WANT)
so reading up on this is so confusing. can I use table.sort, ordered by value, and will that also reorder the key by rrn.
that is lets say now, I have
key 1 val 3
key 2 val 2
key 3 val 1
in my index table ahnentafel
at end, I want
key 1 val 1
key 2 val 2
key 3 val 3
or do I have to put them in new tables
i = 1
caught = 0
for _, val in pairs(anhentafel) do
for k = 1 to (caught= #t) do
if k = val
tblahnen = ahnentafel [val]
tblindi[i} = indiPTR[key]
tblGEN = generation[key]
i = i + 1
caught = caught + 1
end
end
I know I am not correct in the wrong ender quite, but I can figure that out.
or is there even slicker ways to do this for a index table and associated arrays?
I understand the tables are presently keyed by arrival order.
I have tables ahnentafel, indiPTR, generation, their keys are obviously 1..n but the values are not in "order" (that being the order I WANT)
so reading up on this is so confusing. can I use table.sort, ordered by value, and will that also reorder the key by rrn.
that is lets say now, I have
key 1 val 3
key 2 val 2
key 3 val 1
in my index table ahnentafel
at end, I want
key 1 val 1
key 2 val 2
key 3 val 3
or do I have to put them in new tables
i = 1
caught = 0
for _, val in pairs(anhentafel) do
for k = 1 to (caught= #t) do
if k = val
tblahnen = ahnentafel [val]
tblindi[i} = indiPTR[key]
tblGEN = generation[key]
i = i + 1
caught = caught + 1
end
end
I know I am not correct in the wrong ender quite, but I can figure that out.
or is there even slicker ways to do this for a index table and associated arrays?