I have a list of python time values ββthat I extracted from the weblog. I have a list in the format %H:%M:%S How do I sort the time values ββin ascending order?
%H:%M:%S
Just sorted(time_list) works fine.
sorted(time_list)
>>> sorted(["14:10:01", "03:12:08"]) ["03:12:08", "14:10:01"]
sorted([tuple(map(int, d.split(":"))) for d in my_time_list])
Where each item in my_time_list has the form you describe, for example:
>>> my_time_list ["03:12:08", "14:10:01"]
import time sorted((time.strptime(d, "%H:%M:%S") for d in time_list), reverse=True)
you should use the sort(key=str.lower) method sort(key=str.lower) , since your time is parsed as a string
sort(key=str.lower)
Source: https://habr.com/ru/post/949706/More articles:Why did my img error function fail? - javascriptWhy does my dynamic HTML seem to be randomly placed? - jqueryhttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/949703/why-would-the-supplied-alt-text-not-display-when-an-image-fails-to-load&usg=ALkJrhiMgNfeDpeB9qnlIwU5OjQEBPUQaghttps://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/949704/does-mvvmcross-allow-binding-of-viewmodel-properties-to-controls-created-on-the-fly&usg=ALkJrhjsfB4L3qBJ6Si6dB0I_G2sd5mjzAIs there a way to programmatically determine that an image link is bad? - jqueryHow to set the value in the registry through a batch file in Windows? - windowsProblem with hosting a web browser in asp.net mvc applyaton - asp.net-mvcOpenssl speed test for Broadcom engine - performanceHow to export extjs grid data to excel? - extjsOpcache - Clear cache in PHP5.4 and below - phpAll Articles