lua table排序

来源:互联网 发布:借壳上市案例分析 知乎 编辑:程序博客网 时间:2024/06/05 02:08
local temp = {}local arr = {5,"2",1}function temp.sortFunction(a,b)    if(tonumber(a) > tonumber(b)) then -- 从大到小排序        return true    end    return falseendtable.sort( arr, temp.sortFunction)for i = 1 , #arr do    print(arr[i])end
原创粉丝点击