Fix sorting not stable issue

Use std::stable_sort instead of std::sort for column selection sorts.

Fix #12678, close #12680
This commit is contained in:
Coises 2022-12-20 14:13:17 -07:00 committed by Don Ho
parent 3f0f6a2295
commit 5719558588
1 changed files with 4 additions and 4 deletions

View File

@ -87,7 +87,7 @@ public:
// getSortKey() so many times.
if (isSortingSpecificColumns())
{
std::sort(lines.begin(), lines.end(), [this](generic_string a, generic_string b)
std::stable_sort(lines.begin(), lines.end(), [this](generic_string a, generic_string b)
{
if (isDescending())
{
@ -131,7 +131,7 @@ public:
// getSortKey() so many times.
if (isSortingSpecificColumns())
{
std::sort(lines.begin(), lines.end(), [this](generic_string a, generic_string b)
std::stable_sort(lines.begin(), lines.end(), [this](generic_string a, generic_string b)
{
if (isDescending())
{
@ -170,7 +170,7 @@ public:
{
if (isSortingSpecificColumns())
{
std::sort(lines.begin(), lines.end(), [this](generic_string aIn, generic_string bIn)
std::stable_sort(lines.begin(), lines.end(), [this](generic_string aIn, generic_string bIn)
{
generic_string a = getSortKey(aIn);
generic_string b = getSortKey(bIn);
@ -559,7 +559,7 @@ public:
}
assert(nonEmptyInputAsNumbers.size() + empties.size() == lines.size());
const bool descending = isDescending();
std::sort(nonEmptyInputAsNumbers.begin(), nonEmptyInputAsNumbers.end(), [descending](std::pair<size_t, T_Num> a, std::pair<size_t, T_Num> b)
std::stable_sort(nonEmptyInputAsNumbers.begin(), nonEmptyInputAsNumbers.end(), [descending](std::pair<size_t, T_Num> a, std::pair<size_t, T_Num> b)
{
if (descending)
{