From bdfd37c95b2cd541e8c2c69b6964b7cfe4a98e7a Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 17 Aug 2024 15:18:51 +0200 Subject: [PATCH] core: fix sorting of events Fix an embarrassing bug: the less than operator for events was wrong. Signed-off-by: Berthold Stoeger --- core/divecomputer.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/core/divecomputer.cpp b/core/divecomputer.cpp index 06a4defbd..8e6af4189 100644 --- a/core/divecomputer.cpp +++ b/core/divecomputer.cpp @@ -287,11 +287,8 @@ void fixup_dc_duration(struct divecomputer &dc) static bool operator<(const event &ev1, const event &ev2) { - if (ev1.time.seconds < ev2.time.seconds) - return -1; - if (ev1.time.seconds > ev2.time.seconds) - return 1; - return ev1.name < ev2.name; + return std::tie(ev1.time.seconds, ev1.name) < + std::tie(ev2.time.seconds, ev2.name); } int add_event_to_dc(struct divecomputer *dc, struct event ev)