mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-25 14:54:39 +02:00
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:
parent
3f0f6a2295
commit
5719558588
@ -87,7 +87,7 @@ public:
|
|||||||
// getSortKey() so many times.
|
// getSortKey() so many times.
|
||||||
if (isSortingSpecificColumns())
|
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())
|
if (isDescending())
|
||||||
{
|
{
|
||||||
@ -131,7 +131,7 @@ public:
|
|||||||
// getSortKey() so many times.
|
// getSortKey() so many times.
|
||||||
if (isSortingSpecificColumns())
|
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())
|
if (isDescending())
|
||||||
{
|
{
|
||||||
@ -170,7 +170,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (isSortingSpecificColumns())
|
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 a = getSortKey(aIn);
|
||||||
generic_string b = getSortKey(bIn);
|
generic_string b = getSortKey(bIn);
|
||||||
@ -559,7 +559,7 @@ public:
|
|||||||
}
|
}
|
||||||
assert(nonEmptyInputAsNumbers.size() + empties.size() == lines.size());
|
assert(nonEmptyInputAsNumbers.size() + empties.size() == lines.size());
|
||||||
const bool descending = isDescending();
|
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)
|
if (descending)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user