From 1f879f6c66a55dbf180cc9eb9631a55e24295ad1 Mon Sep 17 00:00:00 2001 From: "Vishal Koparde, PhD" Date: Mon, 19 May 2025 11:59:36 -0400 Subject: [PATCH] feat: sorting glob_files by date --- src/ccbr_tools/paths.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ccbr_tools/paths.py b/src/ccbr_tools/paths.py index 8a6dfe3a..77f1f989 100644 --- a/src/ccbr_tools/paths.py +++ b/src/ccbr_tools/paths.py @@ -121,14 +121,16 @@ def glob_files( ]. Returns: - set of pathlib.Path: A set of `pathlib.Path` objects representing the matched files. + set of pathlib.Path: A set of `pathlib.Path` objects representing the matched files + sorted by modification time (newest first) """ - return { + files = [ pathlib.Path(f) for pattern in patterns for f in glob.glob(f"{pipeline_outdir}/**/{pattern}", recursive=True) if pathlib.Path(f).is_file() - } + ] + return sorted(files, key=lambda p: p.stat().st_mtime, reverse=True) def create_tar_archive(files, tar_filename):