From 69ed3bfcd45fc26e1fce01cba731494dc31554f2 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 26 Feb 2014 11:34:20 -0600 Subject: in EdsPlanner's get_appointments(), sort 'em before returning them to the caller. --- src/planner-eds.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/planner-eds.cpp b/src/planner-eds.cpp index da406eb..4f12ec1 100644 --- a/src/planner-eds.cpp +++ b/src/planner-eds.cpp @@ -26,6 +26,7 @@ #include #include +#include // std::sort() #include #include @@ -407,11 +408,17 @@ private: *** walk through the sources to build the appointment list **/ - std::shared_ptr main_task(new Task(this, func), [](Task* task){ + auto task_deleter = [](Task* task){ + // give the caller the (sorted) finished product + auto& a = task->appointments; + std::sort(a.begin(), a.end(), [](const Appointment& a, const Appointment& b){return a.begin < b.begin;}); + task->func(a); + // we're done; delete the task g_debug("time to delete task %p", (void*)task); - task->func(task->appointments); delete task; - }); + }; + + std::shared_ptr main_task(new Task(this, func), task_deleter); for (auto& kv : m_clients) { -- cgit v1.2.3