mirror of
https://github.com/1bardesign/batteries.git
synced 2024-11-22 14:14:36 +00:00
Merge pull request #22 from DUznanski/shuffle-fix
Fix shuffle to avoid bias
This commit is contained in:
commit
c1a4e6898a
@ -173,7 +173,7 @@ end
|
||||
--shuffle the order of a table
|
||||
function tablex.shuffle(t, r)
|
||||
for i = 1, #t do
|
||||
local j = _random(1, #t, r)
|
||||
local j = _random(i, #t, r)
|
||||
t[i], t[j] = t[j], t[i]
|
||||
end
|
||||
return t
|
||||
|
Loading…
Reference in New Issue
Block a user