Medium

Sort Threats by Severity and ExploitabilityPython

Full explanation · Time O(nlogn) · Space O(1)

# Time:  O(nlogn)
# Space: O(1)

# sort
class Solution(object):
    def sortThreats(self, threats):
        """
        :type threats: List[List[int]]
        :rtype: List[List[int]]
        """
        threats.sort(key=lambda x: (-(2*x[1]+x[2]), x[0]))
        return threats