How to descending sort a list of time items in H:M:S format in Python

1 Answer

0 votes
times_list = ['2017-11-05 13:29:21', '2017-11-05 13:29:05', '2017-11-05 16:21:00',
              '2017-11-05 11:40:00', '2017-11-05 14:43:00', '2017-11-05 18:10:00',
              '2017-11-05 15:31:00', '2017-11-05 12:66:00', '2017-11-05 16:15:00']


times_list = sorted(times_list, reverse=True)

print(times_list)


'''
run:

['2017-11-05 18:10:00', '2017-11-05 16:21:00', '2017-11-05 16:15:00', '2017-11-05 15:31:00',
'2017-11-05 14:43:00', '2017-11-05 13:29:21', '2017-11-05 13:29:05', '2017-11-05 12:66:00',
'2017-11-05 11:40:00']

'''

 



answered Nov 5, 2017 by avibootz
...