From 2d07bc7471474c86791c2fd7e45830e9c6b92cd6 Mon Sep 17 00:00:00 2001 From: maru21 Date: Tue, 12 Nov 2024 14:56:25 +0100 Subject: [PATCH] changed sorting to newest in top --- webSimple.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/webSimple.py b/webSimple.py index 3ca5f78..4dcd6e6 100644 --- a/webSimple.py +++ b/webSimple.py @@ -1,4 +1,3 @@ - import os from datetime import datetime @@ -7,7 +6,9 @@ def generate_pdf_list_html(directory, output_file="pdf_list.html"): try: # Get a list of PDF files in the directory file_list = [f for f in os.listdir(directory) if f.endswith('.pdf')] - file_list.sort(key=lambda a: a.lower()) + + # Sort files by modification time (newest first) + file_list.sort(key=lambda f: os.path.getmtime(os.path.join(directory, f)), reverse=True) # Get the current timestamp generation_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")