From f12168b1b98bf93cbf26384187fb81fd2f8cca4f Mon Sep 17 00:00:00 2001 From: Tursiae Date: Sun, 9 Feb 2025 12:35:34 +1100 Subject: [PATCH] Console: Stop `tasks` from hanging in `std::sort`. `std::sort` expects a comparator that returns `a < b`. Flipping this to `a >= b` would normally be fine to reverse the order, but floats behave weirdly with NaN. Instead of flipping the comparator, this uses the reverse-iterators to reverse the sort order of the tasks, and returns to an `a < b` comparator. --- src/tangara/app_console/app_console.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tangara/app_console/app_console.cpp b/src/tangara/app_console/app_console.cpp index 21dec56a..394a47f2 100644 --- a/src/tangara/app_console/app_console.cpp +++ b/src/tangara/app_console/app_console.cpp @@ -286,9 +286,9 @@ int CmdTasks(int argc, char** argv) { } } - std::sort(info_strings.begin(), info_strings.end(), + std::sort(info_strings.rbegin(), info_strings.rend(), [](const auto& first, const auto& second) { - return first.first >= second.first; + return first.first < second.first; }); std::cout << "name\t\t";