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.
develop
Eric Wald 2014-10-21 22:43:56 -06:00
parent b0b6a82c92
commit 169da1342d
1 changed files with 5 additions and 5 deletions

@ -917,7 +917,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
descending = events->count(interface_key::SECONDSCROLL_UP); descending = events->count(interface_key::SECONDSCROLL_UP);
sort_skill = columns[input_column].skill; sort_skill = columns[input_column].skill;
sort_labor = columns[input_column].labor; 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)) if (events->count(interface_key::SECONDSCROLL_PAGEUP) || events->count(interface_key::SECONDSCROLL_PAGEDOWN))
@ -926,16 +926,16 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
switch (input_sort) switch (input_sort)
{ {
case ALTSORT_NAME: case ALTSORT_NAME:
std::sort(units.begin(), units.end(), sortByName); std::stable_sort(units.begin(), units.end(), sortByName);
break; break;
case ALTSORT_PROFESSION_OR_SQUAD: 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; break;
case ALTSORT_HAPPINESS: case ALTSORT_HAPPINESS:
std::sort(units.begin(), units.end(), sortByHappiness); std::stable_sort(units.begin(), units.end(), sortByHappiness);
break; break;
case ALTSORT_ARRIVAL: case ALTSORT_ARRIVAL:
std::sort(units.begin(), units.end(), sortByArrival); std::stable_sort(units.begin(), units.end(), sortByArrival);
break; break;
} }
} }