2 posts
Posted 19 June 2014 - 12:34 AM
Hello All,
A friend of mine made me this program for Thaumcraft and I was wondering how I could get the tables to be orders alphabetically.
The code:
http://pastebin.com/pm0ZNFUACurrently it will just find the jars in order of when they were connected. The reason I would like this to be in alphabetical order is because it creates two lists (side-by-side). One for Void jars and one for normal jars.
Thanks in advance
8543 posts
Posted 19 June 2014 - 12:59 AM
You'd want to use table.sort and provide it a custom function that compared the names from each entry. Check out the Lua documentation on table.sort for more information.
1852 posts
Location
Sweden
Posted 19 June 2014 - 01:20 AM
Isn't there anyone searching before posting? I feel like there was a similiar question like this just recently.
7083 posts
Location
Tasmania (AU)
Posted 19 June 2014 - 03:24 AM
It seems to get like this every time Dire releases a CC-related video.
In any case,
this may be worth a read.
2 posts
Posted 19 June 2014 - 03:25 AM
You'd want to use table.sort and provide it a custom function that compared the names from each entry. Check out the Lua documentation on table.sort for more information.
I have tried but I have no real idea how to implement it (I did not find the LUA documentation on table.sort() to be very helpful)
Isn't there anyone searching before posting? I feel like there was a similiar question like this just recently.
I tried looking but didn't really find much
389 posts
Location
Norway
Posted 21 June 2014 - 08:42 PM
Lua can allready use <, >, etc on strings. You don't need to specify any special function to table.sort(), it will work just fine.
Eyes please <_</>
Edited on 21 June 2014 - 06:53 PM
8543 posts
Posted 21 June 2014 - 08:52 PM
It would work fine if his table were a table of strings, but it's actually a table of tables of functions, so he'll need to write a custom function for sorting that gets the name of each from the function in each table, then compare those and return true or false based on that comparison. Then he'll need to use that function with table.sort.