diff --git a/xfel_calibrate/finalize.py b/xfel_calibrate/finalize.py
index 92f833783a05865eb78eaa88371f9ea7fd995f86..53bc72912ff3cbe105f9732fa0b7b78c8dd4d596 100644
--- a/xfel_calibrate/finalize.py
+++ b/xfel_calibrate/finalize.py
@@ -273,7 +273,7 @@ def make_report(run_path, tmp_path, out_path, project, author, version,
             return len(lead_rstfiles) + 1, f
         else:
             return len(lead_rstfiles) + 2, f
-    lead_rstfiles.sort(key=sort_key)
+    direntries.sort(key=sort_key)
 
     files_to_handle = []
     for entry in direntries: