What is the best way to get a list of all files in a directory, sorted by date [created | modified], using python, on a windows machine?
There is an os.path.getmtime function that gives the number of seconds since the epoch and should be faster than os.stat.
os.path.getmtime
os.stat
import os os.chdir(directory) sorted(filter(os.path.isfile, os.listdir('.')), key=os.path.getmtime)