get_key(log)
that takes a log entry and returns a sorting key tuple based on the rules described above.get_key(log)
, split the log into two parts: the identifier and the content.(0, content, identifier)
.(1, None, None)
.sorted()
function with the custom key get_key
to sort the logs.