

Given a list of log lines as strings, where each valid line is a JSON object containing at least level and message, write a function that returns a list of [message, count] pairs for all logs whose level is "ERROR". Ignore invalid JSON lines and valid lines missing either required field. Sort the result by descending count, then by ascending message for ties.
Example 1:
Input: logs = ['{"level":"ERROR","message":"timeout"}', '{"level":"INFO","message":"start"}', '{"level":"ERROR","message":"timeout"}', '{"level":"ERROR","message":"disk full"}']
Output: [["timeout", 2], ["disk full", 1]]
Explanation: Only ERROR entries are counted, and "timeout" appears twice.
Example 2:
Input: logs = ['{"level":"WARN","message":"retry"}', 'not-json', '{"level":"ERROR","message":"retry"}', '{"level":"ERROR"}']
Output: [["retry", 1]]
Explanation: The invalid JSON line and the missing-message line are ignored.
1 <= len(logs) <= 10^41 and 10^3Given a list of log lines as strings, where each valid line is a JSON object containing at least level and message, write a function that returns a list of [message, count] pairs for all logs whose level is "ERROR". Ignore invalid JSON lines and valid lines missing either required field. Sort the result by descending count, then by ascending message for ties.
Example 1:
Input: logs = ['{"level":"ERROR","message":"timeout"}', '{"level":"INFO","message":"start"}', '{"level":"ERROR","message":"timeout"}', '{"level":"ERROR","message":"disk full"}']
Output: [["timeout", 2], ["disk full", 1]]
Explanation: Only ERROR entries are counted, and "timeout" appears twice.
Example 2:
Input: logs = ['{"level":"WARN","message":"retry"}', 'not-json', '{"level":"ERROR","message":"retry"}', '{"level":"ERROR"}']
Output: [["retry", 1]]
Explanation: The invalid JSON line and the missing-message line are ignored.
1 <= len(logs) <= 10^41 and 10^3