Invalid order function for sorting is getting REALLY AND REALLY ANNOYING

invalid order function for sorting

i have no idea at all what i’m doing wrong.

table.sort(newTable, function(a, b)

    local aPower = gameData.Pets[a.Name].Power

    local bPower = gameData.Pets[b.Name].Power

    if a.Big == true and a.Gold == false then

        aPower *= 1.20

    end

    if a.Big == true and a.Gold == true then

        aPower *= 1.70

        print(aPower)

    end

    if a.Huge == true and a.Gold == false then

        aPower *= 1.50

    end

    if a.Huge == true and a.Gold == true then

        aPower *= 2

    end
    
    if a.Equipped == b.Equipped then
        
        return aPower > bPower
        
    end
    
    return a.Equipped and not b.Equipped
    
end)

i fixed this by splitting functions,

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.