Iwasawa Posted March 30, 2015 Share Posted March 30, 2015 Help me please! I need help with table sorting, im working on AI racers script, and it works fairly good already, but i need to sort them by how many cps did they collect. So i have the Vehicles as keys and the CP collected as value. How can i sort by value? I store the keys as data in the vehicles so i can access the names table with the key of the vehicle.(the AI has names) Link to comment
Iwasawa Posted March 30, 2015 Author Share Posted March 30, 2015 OR, is it a working solution to just refresh the whole table in every sec? I mean, i create a new empty table, and add them sorted by their points. Then next sec clear the table and do the same again. Or how do you do this? Link to comment
Ryancit2 Posted March 30, 2015 Share Posted March 30, 2015 Clearing the table won't hurt, perhaps a code provided would help us more efficiently to let you know better choice. Although, refreshing tables isn't really CPU-Consuming stuff unless it is related with hugeass database. Link to comment
Et-win Posted March 30, 2015 Share Posted March 30, 2015 table.sort(table, function(var1, var2) return var1[1] < var2[1] end) Change to the index where the values are stored. Link to comment
Iwasawa Posted March 30, 2015 Author Share Posted March 30, 2015 I dont understand that etwin. How could i sort a 60 entry table with this method? Link to comment
Et-win Posted March 31, 2015 Share Posted March 31, 2015 It will. Make a table and run this one time. 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