Lua数组排序

代码

network = {
{name = "grauna", IP = "210.26.30.34"},
{name = "arraial", IP = "210.26.30.23"},
{name = "lua", IP = "210.26.23.12"},
{name = "derain", IP = "210.26.23.20"},
{name = "C++", IP = "210.26.23.22"},
} -- 增加 string.lower 为忽略大小写。
table.sort(network, function (a,b)
return (string.lower( a.name) < string.lower(b.name))
end) -- 将network的所有成员显示出来
for k,v in pairs(network) do
print(k,v.name)
end

测试

Lua数组排序

上一篇:常见的SQL字符串函数


下一篇:记一次gitlab添加账号收不到邮件的解决办法