so basically whenever the player has some money, over 1000, I want that 1000 to be sorted as 1,000
the same for 1000000, I need it to be 1,000,000
how do I sort something like this
so basically whenever the player has some money, over 1000, I want that 1000 to be sorted as 1,000
the same for 1000000, I need it to be 1,000,000
how do I sort something like this
local Numbers = {"1,000", "500", "2,000", "3,000,000"}
table.sort(Numbers, function(Left, Right)
Left, Right = string.gsub(Left, ",", ""), string.gsub(Right, ",", "")
Left, Right = tonumber(Left), tonumber(Right)
return Left > Right
end)
for _, Number in ipairs(Numbers) do
print(Number)
end
--3,000,000
--2,000
--1,000
--500