How can i sort this listing in PYTHON by folder creation?

Is there anything i can do about this code? I need to sort it by folder creation, the newest will be first ... thx :slight_smile:

for dirname in postme:

                                      dirname = os.path.abspath(dirname)

                                      if dirname:

                                          self._gal_files(os.path.basename(dirname), os.listdir(dirname), basepath=dirname)

Please let us know which OS you're using. It is important for this question because on most *nix flavours, the creation time is not stored in filesystem.

On windows, you can use os.stat('C:\path\to\dir').st_ctime

From python docs:

os.stat(path):
    .
    .
    st_ctime - platform dependent; time of most recent metadata change on Unix, or the time of creation on Windows)
1 Like

its ubuntu 16 :slight_smile: