|
1 | 1 | #include "CountryInstanceManager.hpp" |
| 2 | +#include <algorithm> |
2 | 3 |
|
3 | 4 | #include "openvic-simulation/country/CountryDefinition.hpp" |
4 | 5 | #include "openvic-simulation/defines/CountryDefines.hpp" |
@@ -59,27 +60,27 @@ void CountryInstanceManager::update_rankings(const Date today) { |
59 | 60 | industrial_power_ranking = total_ranking; |
60 | 61 | military_power_ranking = total_ranking; |
61 | 62 |
|
62 | | - std::sort( |
| 63 | + std::stable_sort( |
63 | 64 | total_ranking.begin(), total_ranking.end(), |
64 | 65 | [](CountryInstance* a, CountryInstance* b) -> bool { |
65 | 66 | const bool a_civilised = a->is_civilised(); |
66 | 67 | const bool b_civilised = b->is_civilised(); |
67 | 68 | return a_civilised != b_civilised ? a_civilised : a->total_score.get_untracked() > b->total_score.get_untracked(); |
68 | 69 | } |
69 | 70 | ); |
70 | | - std::sort( |
| 71 | + std::stable_sort( |
71 | 72 | prestige_ranking.begin(), prestige_ranking.end(), |
72 | 73 | [](CountryInstance const* a, CountryInstance const* b) -> bool { |
73 | 74 | return a->get_prestige_untracked() > b->get_prestige_untracked(); |
74 | 75 | } |
75 | 76 | ); |
76 | | - std::sort( |
| 77 | + std::stable_sort( |
77 | 78 | industrial_power_ranking.begin(), industrial_power_ranking.end(), |
78 | 79 | [](CountryInstance const* a, CountryInstance const* b) -> bool { |
79 | 80 | return a->get_industrial_power_untracked() > b->get_industrial_power_untracked(); |
80 | 81 | } |
81 | 82 | ); |
82 | | - std::sort( |
| 83 | + std::stable_sort( |
83 | 84 | military_power_ranking.begin(), military_power_ranking.end(), |
84 | 85 | [](CountryInstance* a, CountryInstance* b) -> bool { |
85 | 86 | return a->military_power.get_untracked() > b->military_power.get_untracked(); |
@@ -158,7 +159,7 @@ void CountryInstanceManager::update_rankings(const Date today) { |
158 | 159 |
|
159 | 160 | // Sort the great powers list by total rank, as pre-existing great powers may have changed rank order and new great |
160 | 161 | // powers will have been added to the end of the list regardless of rank. |
161 | | - std::sort(great_powers.begin(), great_powers.end(), [](CountryInstance const* a, CountryInstance const* b) -> bool { |
| 162 | + std::stable_sort(great_powers.begin(), great_powers.end(), [](CountryInstance const* a, CountryInstance const* b) -> bool { |
162 | 163 | return a->get_total_rank() < b->get_total_rank(); |
163 | 164 | }); |
164 | 165 |
|
|
0 commit comments