How to sort a list of time values?

后端 未结 4 812
再見小時候
再見小時候 2020-12-16 03:47

I have a python list of time values that I extracted from a web log. I have the list in the format of %H:%M:%S. How would I sort the time values in ascending o

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-16 03:58

    sorted([tuple(map(int, d.split(":"))) for d in my_time_list])
    

    Where each element in my_time_list is of the form you describe, for example:

    >>> my_time_list
    ["03:12:08", "14:10:01"]
    

提交回复
热议问题