KariiiM Posted September 21, 2015 Share Posted September 21, 2015 Hey guys, Anyone know a LUA Function that is able to make a list of numbers in order , like 1,2,3,4... For example, i have a table looking like that: local aTable= { {4, "row4"}, {2, "row2"}, {1, "row1"}, {3, "row3"}, } and after using this function it should be in order like this example below: (im sure there's a lua function for that just i didn't search well) local aTable= { {1, "row1"}, {2, "row2"}, {3, "row3"}, {4, "row4"}, } Link to comment
Dealman Posted September 21, 2015 Share Posted September 21, 2015 Do the integers have any specific meaning, or does it just act as an ID for the row? If so, you could do this; local aTable = { [4] = "row4", [2] = "row2", [1] = "row1", [3] = "row3", } table.sort(aTable) for i=1, 4 do print(aTable[i]) end I suggest you use a website such as repl.it and you can try things like these directly in your browser. Link to comment
KariiiM Posted September 21, 2015 Author Share Posted September 21, 2015 Yes this function what i was searching for, thanks ! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now