How do I sort this table {string{string,int,int}}

I have a table of date that is to be returned from a server script via invokeserver.
The table is built from a selection of tables in the server script.
The table is defined with
loacl table = {}
The code in a loop to set one entry in the table is
table[string1] = {string1, int1, int2}

The client needs the table be sorted in order.

I have tried table.sort(tablename,function(a,b) return a<b end) but when I print out the table it is not sorted.

Can someone please suggest how I can get this table sorted.

sort in what order

0000000000000000000000

I want the index as in {index{string,int,int}} to be in alphabetical order A-Z

change the a<b thing to string.lower(a[1]) < string.lower(b[1])

1 Like

assuming that the 1st element is the string youre trying to sort

so you want to turn a dictionary into a sorted array?

I need to be able to access the data by using a value for the index and then get the values for the ints.
For example say the index is “Dirt” then I would get the values by using table[“Dirt”][2] for the first int and
table[“Dirt”][3] for the second one.

this is an array not a dictionary which means that it will get sent that way to the client

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.