having a issue with shuffling values in a table
I’m using the following code
local function shuffle(t) local rand = math.random assert(t, "table.shuffle() expected a table, got nil") local iterations = #t local j for i = iterations, 2, -1 do j = rand(i) t[i], t[j] = t[j], t[i] end end
it shuffles the values in the table no problem but when I run the app on multiple devices at the same time it shows the values from the shuffled table in the same order
so for eg
table = {“a”, “b”, “c”, “d”, “e”}
shuffle(table)
output:
iDevice 1 = {“d”, “a”, “e”, “c”, “b”}
iDevice 2 = {“d”, “a”, “e”, “c”, “b”}
iDevice 3 = {“d”, “a”, “e”, “c”, “b”}
surely the shuffled table should be different for each one??
I’m really stumped on this, can anyone help me with a fix or a different way to code it??