I found "sort" does not always do what I expected. eg, I have a directory as below, and the "sort" give me a very strange result:
>>> os.listdir(pathon)
['2', '3', '4', '5', '403', '404', '407', '408', '410', '411', '412', '413', '414', '415', '416', '472']
>>> sorted([ f for f in os.listdir(pathon)])
['2', '3', '4', '403', '404', '407', '408', '410', '411', '412', '413', '414', '415', '416', '472', '5']
It seems it compares the first character first, if that is the biggest, it would be the last one.