I have code like so, everything work, except for the fact that the table doesn't sort, which is obviously the most important part. Can anyone find out what wrong? I certainly can't, Any help would be much appreciated.
Yes the number I am sorting does get updated, I tried with both and it still return the same results...
local function SelectMap()
local Votes = {{"BridgeBrigade", 0}, {"Map2", 0}}
for _, Player in pairs(PlayersService:GetPlayers()) do
if Player:FindFirstChild("Votes") then
for Index, Value in pairs(Votes) do
if Votes[Index][1] == Player.Votes.Map.Value then
Votes[Index][2] = Votes[Index][2] + 1
end
end
end
end
table.sort(Votes, function(A, B) --This isn't sorting...
print(A[1], B[1])
return A[2] < B[2]
end)
print(Votes[1][1])
end
[ UPDATE ]
So I just did some debug tests and apparently "Map2" is a nil value but the value in the same table isn't. That strange

3 comments
I did debug it, and after alot of work I got it to work. Sorry, I kind of forgotten to post here, but what was that about the Dictionary? and making it easier to understand. Could you explain?
Edited to add explanation
Thanks :)