From 36b62260b155b52daf3f5fc226f91bfc0b5abd12 Mon Sep 17 00:00:00 2001
From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr>
Date: Tue, 27 Feb 2024 15:40:21 +0100
Subject: [PATCH] Results: Fix results export.

---
 src/View/Results/Window.py | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/View/Results/Window.py b/src/View/Results/Window.py
index f154eb3d..45aaa009 100644
--- a/src/View/Results/Window.py
+++ b/src/View/Results/Window.py
@@ -614,12 +614,11 @@ class ResultsWindow(PamhyrWindow):
                                 quotechar='|', quoting=csv.QUOTE_MINIMAL)
 
             writer.writerow(["timestamp", "z", "q"])
-            for profile in reach.profiles:
-                timestamps = self._results.get("timestamps")
-
-                for ts in timestamps:
-                    writer.writerow([
-                        ts,
-                        profile.get_ts_key(ts, "Z"),
-                        profile.get_ts_key(ts, "Q"),
-                    ])
+            timestamps = sorted(self._results.get("timestamps"))
+
+            for ts in timestamps:
+                writer.writerow([
+                    ts,
+                    profile.get_ts_key(ts, "Z"),
+                    profile.get_ts_key(ts, "Q"),
+                ])
-- 
GitLab