Hi there I’m trying to sort this list, but table.sort keeps returning nil
This is my table. I’m trying to get a table ordered alphabetically by hero.
local heroes =
{
{
["hero"] = "Zack",
["hp"] = 70,
["attack"] = 10,
},
{
["hero"] = "Mark",
["hp"] = 60,
["attack"] = 30,
},{
["hero"] = "Beto",
["hp"] = 99,
["attack"] = 60,
},
}
local function sort_abc(a,b)
return a.hero < b.hero
end
heroes = table.sort(heroes, sort_abc)
pprint(heroes)
Nevertheless pprint, prints nil.
I tried with something simple such as:
local t = {5,7,3}
t = table.sort(t)
pprint(t)
With the same result.
Could anyone explain me what’s going on?
Thanks a lot.