local Tab = {Xd = 'G', ge = 'g',ce = 'gg',keke = '1', fefe = '2'}
What if I wanted to move Xd to first
and ge to last
what would I do?
COMMUNITY QUESTION
How would I move a key in a table to a different array?
1 answer
You can pretty easily reference the values that you wanna put into the other table and just copy em' over. You can do it like so:
local newtbl = {}
local Tab = {Xd = 'G', ge = 'g',ce = 'gg',keke = '1', fefe = '2'}
newtbl.Xd = Tab.Xd
newtbl.ge = Tab.ge
Or, if you're converting the table into a regular old array, you can use table.insert() and it will automatically insert it for you, in order.
local newtbl = {}
local Tab = {Xd = 'G', ge = 'g',ce = 'gg',keke = '1', fefe = '2'}
table.insert(newtbl,Tab.Xd)
table.insert(newtbl,Tab.ge)
Hope this helps! If you have any further questions feel free to comment or look things up on the devforum.
3 comments
1
All you did was make a new table, not actually change the original table
0
the original question was about moving a key to a different table, not rearranging in the same one
0
yes it is, you just couldn't interpret it
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Dictionaries are unordered, so it is impossible to do what you want and get the expected output when you're iterating over it.over it