summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTursiae <git@tursiae.org>2025-02-09 12:35:34 +1100
committerTursiae <git@tursiae.org>2025-02-09 12:35:34 +1100
commitf12168b1b98bf93cbf26384187fb81fd2f8cca4f (patch)
tree867b9c115e0bf40ba592edd06cdf14f658113c1a
parent5275b5ebcba3afed4280accaf57407a68b305021 (diff)
downloadtangara-fw-f12168b1b98bf93cbf26384187fb81fd2f8cca4f.tar.gz
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.
-rw-r--r--src/tangara/app_console/app_console.cpp4
1 files 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";