From 169da1342d3eaffc8252d614bdebeff120e85f14 Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Tue, 21 Oct 2014 22:43:56 -0600 Subject: [PATCH 1/2] Switching Dwarf Manipulator to a stable sort. This means, for example, that when you sort by one skill, then by a second, dwarves with the first skill but not the second will still be grouped together. --- plugins/manipulator.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index ebd23a9d7..c1f585c3f 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -917,7 +917,7 @@ void viewscreen_unitlaborsst::feed(set *events) descending = events->count(interface_key::SECONDSCROLL_UP); sort_skill = columns[input_column].skill; sort_labor = columns[input_column].labor; - std::sort(units.begin(), units.end(), sortBySkill); + std::stable_sort(units.begin(), units.end(), sortBySkill); } if (events->count(interface_key::SECONDSCROLL_PAGEUP) || events->count(interface_key::SECONDSCROLL_PAGEDOWN)) @@ -926,16 +926,16 @@ void viewscreen_unitlaborsst::feed(set *events) switch (input_sort) { case ALTSORT_NAME: - std::sort(units.begin(), units.end(), sortByName); + std::stable_sort(units.begin(), units.end(), sortByName); break; case ALTSORT_PROFESSION_OR_SQUAD: - std::sort(units.begin(), units.end(), show_squad ? sortBySquad : sortByProfession); + std::stable_sort(units.begin(), units.end(), show_squad ? sortBySquad : sortByProfession); break; case ALTSORT_HAPPINESS: - std::sort(units.begin(), units.end(), sortByHappiness); + std::stable_sort(units.begin(), units.end(), sortByHappiness); break; case ALTSORT_ARRIVAL: - std::sort(units.begin(), units.end(), sortByArrival); + std::stable_sort(units.begin(), units.end(), sortByArrival); break; } } From ac73c0eeba2a3d1b67e00d7a94c7c20e90b760dc Mon Sep 17 00:00:00 2001 From: Eric Wald Date: Tue, 21 Oct 2014 22:49:50 -0600 Subject: [PATCH 2/2] Allowing non-labor skills to sort stably. --- plugins/manipulator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index c1f585c3f..296048fb5 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -363,7 +363,7 @@ bool sortBySkill (const UnitInfo *d1, const UnitInfo *d2) else return d1->unit->status.labors[sort_labor] < d2->unit->status.labors[sort_labor]; } - return sortByName(d1, d2); + return false; } enum display_columns {