I am completely new to python and I have a serious problem which I cannot solve.
I have a few log files with identical structure:
[timestamp] [level]
As for the critical sorting function:
def sort_key(line):
return datetime.strptime(line.split(']')[0], '[%a %b %d %H:%M:%S %Y')
This should be used as the key argument to sort or sorted, not as cmp. It is faster this way.
Oh, and you should have
from datetime import datetime
in your code to make this work.