You should use the Fisher-Yates shuffle instead. The methods posted here aren’t uniform.
local function shuffle(t)
local j, temp
for i = #t, 1, -1 do
j = math.random(i)
temp = t[i]
t[i] = t[j]
t[j] = temp
end
end
You should use the Fisher-Yates shuffle instead. The methods posted here aren’t uniform.
local function shuffle(t)
local j, temp
for i = #t, 1, -1 do
j = math.random(i)
temp = t[i]
t[i] = t[j]
t[j] = temp
end
end