t = {
{lv = 1 , score =2,id = 1 },
{lv = 1 , score =2 ,id = 2},
{lv = 1 , score =2 ,id = 3},
{lv = 1 , score =2 ,id = 4}
}
function compFunc(a, b)
if a.score == b.score then
if a.lv == b.lv then
return true -- return true cause "invalid order function for sorting" , must return false here
else
return a.lv > b.lv
end
else
return a.score > b.score
end
end
table.sort(t,compFunc)
{lv = 1 , score =2,id = 1 },
{lv = 1 , score =2 ,id = 2},
{lv = 1 , score =2 ,id = 3},
{lv = 1 , score =2 ,id = 4}
}
function compFunc(a, b)
if a.score == b.score then
if a.lv == b.lv then
return true -- return true cause "invalid order function for sorting" , must return false here
else
return a.lv > b.lv
end
else
return a.score > b.score
end
end
table.sort(t,compFunc)