I'm trying to sort a list of dates that are in string format but are each in different form, like this:
lst = ['11/04/2016, 23:55', '15/11/2014', '04/05/2016, 23:55', '24/11/2013, 12:30', '31/12/2015']
I've tried the following sorting:
lst.sort(key=lambda date: datetime.strptime(date, "%d/%m/%Y, %H:%M"))
But since I do not know how the dates will be (with the specific hour or without) I got stuck.. I couldn't think of a generic condition to sort this list and I need to keep the exact time if it is given (i.e I don't want to split the string and take only what's before the ,
).
Please help :(