I have the following 2D array, the date format is %Y-%m-%d %H:%M:%S :
[['second comment test', datetime.datetime(2018, 8, 22, 15, 49, 40), 's']
['this comment originated in service now', datetime.datetime(2018, 8, 22, 14, 45), 's']
['this is a longer description used for testing', datetime.datetime(2018, 8, 22, 14, 13, 49), 'z']]
I noticed that if one of the logs for time is at exactly a minute for example 2018-08-22 14:45:00 Meaning that it ends in 00 it wont log the seconds. So how can I order this array by date?
arr.sort(key=lambda x: x[1])will sort by the second element in each list if your list is namedarr. This will sort in-place.datetimeobjects are stored internally as integers. Not sure why you think you havedate format is %Y..... As such, sorting will work regardless of the seconds value being 0.