Im trying to iterate over files but want to the newer file get iterated first.
import os
directory = os.getcwd() + "\\Images"
for file in os.listdir(directory):
filename = os.fsdecode(file)
if filename.endswith(".png") or filename.endswith(".jpg"):
#blablabla
This code works fine but it iterates sorted by file name instead of creation time. How can this be done?