diff --git a/README.md b/README.md
index 16f4c8c..1f2bb28 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@
- Image proxying
- Gallery/album proxying
- - Proper order of gallery posts
+ - Proper order of gallery posts
- Image description and author info
- Tor/SOCKS support for block circumvention
- GIFs/videos (For now use youtube-dl)
diff --git a/imgin/__init__.py b/imgin/__init__.py
index aff5747..38ad481 100644
--- a/imgin/__init__.py
+++ b/imgin/__init__.py
@@ -2,7 +2,7 @@ from gevent import monkey
from gevent import sleep
monkey.patch_all()
from threading import Thread
-from os import remove, mkdir, path
+from os import remove, mkdir, path, stat
from shutil import rmtree
from glob import glob
@@ -16,6 +16,9 @@ from .get import get
from .config import IMAGE_CACHE, SINGLE_IMAGE_DELETE_AFTER_SECS, ALBUM_DELETE_AFTER_SECS, template_dir
+def get_timestamp_of_file(file):
+ return stat(file).st_ctime
+
def album(id):
req_id = str(uuid4())
req = IMAGE_CACHE
@@ -23,8 +26,15 @@ def album(id):
get("/a/" + id, req)
imgs = glob(req + "*")
+
+ # sort image order (file creation time)
+ imgs = sorted(imgs, key=get_timestamp_of_file)
+
for c, img in enumerate(imgs):
imgs[c] = img.replace(IMAGE_CACHE, '/')
+
+
+
with open(f'{template_dir}gallery.html', 'r') as img_view:
tpl = SimpleTemplate(img_view)
return tpl.render(imgs=imgs)
diff --git a/imgin/web/index.html b/imgin/web/index.html
index dd38ec2..33b9a94 100644
--- a/imgin/web/index.html
+++ b/imgin/web/index.html
@@ -25,7 +25,7 @@