I am wondering if anyone can confirm if you can trust ipairs() to; return all indexes in order, for a table that contains an index but is unsorted.
We have code throughout our project that clones tables using pairs() , however any cloned arrays are returned unordered. I am not sure if this is a problem.
For comparison:
A = {10, 20, 30, 40, 50, 60}
in
B = {[1] = 10, [2] = 20, [3] = 30, [4] = 40, [5] = 50, [6] = 60}
If you loop them on pairs() , the first is ordered, and the other is not. (On a side note, B unexpectedly sorted if you do a couple of back inserts)
Return to the original question. It seems that B above iterates all the values in order using ipairs() , but is it always guaranteed?
source share