table.sort(list) //默认按照升序排序,但是当存在相等比较时,每次调用后顺序会不定
--自定义排序规则
table.sort(list,function(a,b)
if(a.num > b.num) then
return true --num降序
elseif(a.num == b.num) then
if(a.count < b.count) then
return true --count 升序
elseif(a.count == b.count) then
return a.id > b.id --id降序
end
return false
end)
Lua - table.sort 排序
猜你喜欢
转载自blog.csdn.net/smile_otl/article/details/134883313
今日推荐
周排行