How to list the files in a directory based on timestamp?
os.listdir()
lists in arbitrary order.
Is there a build-in function to list based on timestamp? or by any order?
How to list the files in a directory based on timestamp?
os.listdir()
lists in arbitrary order.
Is there a build-in function to list based on timestamp? or by any order?
My immediate solution is,
As per the duplicate post pointed by bluish, this is a bad solution; why is it bad?
You could call
stat()
on each of the files and sort by one of the timestamps, perhaps by using a key function that returns a file's timestamp.