Test results currently depend on how compare-equal elements are sorted by std::sort's unstable sort. Defaulting to std::stable_sort avoids that problem and generally increases the determinism of the code, which is good.
If there are specific cases where the (fairly small) performance overhead of stable sorting is a concern, those can be switched back to unstable sorting as an optimization, but first one would need to verify that that doesn't break the tests (e.g., by running the tests with a shuffle before each call to unstable sort).
Verified no significant performance degradation in the experiments when doing the suggested replacement.
Thank you for identifying this source of non-determinism!
Test results currently depend on how compare-equal elements are sorted by
std::sort
's unstable sort. Defaulting tostd::stable_sort
avoids that problem and generally increases the determinism of the code, which is good.If there are specific cases where the (fairly small) performance overhead of stable sorting is a concern, those can be switched back to unstable sorting as an optimization, but first one would need to verify that that doesn't break the tests (e.g., by running the tests with a shuffle before each call to unstable sort).
Resolves #654