Merge pull request #365 from eswald/stable-sorting

Stable sorting for Dwarf Manipulator
develop
expwnent 2014-11-02 03:26:14 -05:00
commit 0fd15cc1e4
1 changed files with 6 additions and 6 deletions

@ -363,7 +363,7 @@ bool sortBySkill (const UnitInfo *d1, const UnitInfo *d2)
else else
return d1->unit->status.labors[sort_labor] < d2->unit->status.labors[sort_labor]; return d1->unit->status.labors[sort_labor] < d2->unit->status.labors[sort_labor];
} }
return sortByName(d1, d2); return false;
} }
enum display_columns { enum display_columns {
@ -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;
} }
} }