Scripting: implement a simplified Linux tool such as ps or find, or parse logs.
Asked in the Scripting stage. Implement parse_logs(lines, level) to process structured log lines.
Each line has the form timestamp level process message, with fields separated by single spaces. Return a list of [process, count] pairs for lines whose level equals level. Sort by descending count, then ascending process name. All input lines are valid, and the message may contain spaces.
Example 1: lines = ["10:00 INFO worker started", "10:01 ERROR api failed", "10:02 ERROR worker retrying"], level = "ERROR" returns [["api", 1], ["worker", 1]].
Example 2: lines = ["10:00 WARN api slow", "10:01 WARN api retry", "10:02 INFO worker done"], level = "WARN" returns [["api", 2]].
def parse_logs(lines, level):