VE Lua Documentation

Press F to search!

shuffledPairs

Definition


-- @/lua/common/utils.lua:1438

-- like pairs but in guaranteed random order
function shuffledPairs(t, ctx)
  if ctx then
    table.clear(ctx)
  else
    ctx = table.new(#t, 2)
  end
  local i = 0
  for k in pairs(t) do
    i = i + 1
    ctx[i] = k
  end
  arrayShuffle(ctx)
  ctx.i, ctx.t = 1, t
  return pairs_it, ctx
end

Callers