Lua 打乱数组顺序

xiaoxiao2021-02-28  94

function shuffle(t) if type(t)~="table" then return end local tab={} local index=1 while #t~=0 do local n=math.random(0,#t) if t[n]~=nil then tab[index]=t[n] table.remove(t,n) index=index+1 end end return tab end
转载请注明原文地址: https://www.6miu.com/read-70582.html

最新回复(0)