【发布时间】:2009-11-01 15:53:06
【问题描述】:
我正在尝试排序,但结果为零。我该如何解决这个问题?
我正在使用的代码:(按名称和 HP 对其进行排序。以防有重复的 HP)
T = { {Name = "Mark", HP = 54, Breed = "Ghost"},
{Name = "Stan", HP = 24, Breed = "Zombie"},
{Name = "Juli", HP = 100, Breed = "Human"},
{ HP = 100, Breed = "Human"}
}
function Sorting(T)
table.sort(T,
function(x,y)
return x.Name < y.Name and x.HP < y.HP
end
)
end
【问题讨论】:
-
使用缩进自动格式化代码示例。
标签: lua