The Random data type generates pseudorandom numbers and directions.
local max = 2147483647 -- use a large integer
local seed = math.random(max)
local generator = Random.new(seed)
Uniformly shuffles the array part of tb in-place using NextInteger to pick indices. If there are any nil "holes" in the array part of the table, Shuffle throws an error, since shuffling could change the length.
The hash part of tb is ignored. No metamethods of tb are invoked.
The shuffle is defined to be a Fisher-Yates shuffle so the number of NextInteger calls is guaranteed to be consistent between engine versions for a given size of table.