Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does my table change order on its own?

Asked by 3 years ago

Hi so the problem that I am having is I have this table shown down bellow for my admin scripts.

local ranks = {
    ['Mod'] = {
        User = {},
        lvl = 1,
        Group = {"9851094,255"}
    };
    ['HeadAdmin'] = {
        User = {},
        lvl = 3,
        Group = {"9851094,255"}
    };
    ['Admin'] = {
        User = {},
        lvl = 2,
        Group = {"9851094,255"}
    };

}

No matter what order I put the sections of the table in it always produces me with the same way of listing order.

 ?  {
                    ["Admin"] =  ? {...},
                    ["HeadAdmin"] =  ? {...},
                    ["Mod"] =  ? {...}
                 } 

Can someone explain how to fix this or atleast give me a resource that could help me fix it myself?

0
By default, it appears Roblox sorts using the Ascii values of the characters in the strings. As "A" is before "H" and "H" is before "M", your table being ordered in that way makes sense. You could try using the table.sort function with a custom 'comp' function to fix the sorting. appxritixn 2235 — 3y
0
I will test it and see if that works and if it does thanks ExecutiveJoe 5 — 3y

Answer this question