LUA 表排序
t = { [1] = 1, [344222] = 12, [223232] = 20} for k, v in pairs(t) do--注意这个输出顺序是没有规律的!!! print(k, v) end local keys = {} for k, _ in pairs(t) do table.insert(keys, k) end function cmp(v1, v2) return v1 > v2 end print("---------------------") table.sort(keys, function(v1, v2) return v1 > v2 end) for _, v in pairs(keys) do print(v, t[v]) end