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?
# *** the shortest and best way *** # getmtime --> sort by modified time # getctime --> sort by created time import glob,os lst_files = glob.glob("*.txt") lst_files.sort(key=os.path.getmtime) print("\n".join(lst_files))