function copy(tab)
local ret = {}
for _,v in pairs(tab) do
table.insert(ret, v)
end
return ret
end
function sortPokemonsArray(pokemons)
math.randomseed(os.time())
local used = copy(pokemons)
local sortedPokes = {}
for i = 1, #pokemons do
local i= math.random(#used)
table.insert(sortedPokes, used[i])
table.remove(used, i)
used = copy(used)
end
return sortedPokes
end
local pokemons = {
{name = "Vaporeon", level = 250, nick = "", ball = "normal"},
{name = "Gyarados", level = 300, nick = "", ball = "normal"},
{name = "Tentacruel", level = 320, nick = "", ball = "normal"},
{name = "Golduck", level = 330, nick = "", ball = "normal"},
{name = "Blastoise", level = 350, nick = "", ball = "normal"},
{name = "Starmie", level = 400, nick = "", ball = "normal"},
}
local sorted = sortPokemonsArray(pokemons)
-- string serializada
local sorted_str = table.serialize(sorted)
-- table unserialize
local pokes = table.unserialize(sorted_str)