mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-08 21:04:26 +00:00
Fixed naturalSort. When a single digit number was followed by text+numbers, the string wouldn't sort correctly.
This commit is contained in:
parent
a1f82db5d5
commit
f276ad568e
13
src/misc.cpp
13
src/misc.cpp
@ -536,18 +536,6 @@ bool misc::naturalSort(QString left, QString right, bool &result) { // uses less
|
|||||||
else if (left.left(posL) != right.left(posR))
|
else if (left.left(posL) != right.left(posR))
|
||||||
break; // Strings' subsets before digit do not match
|
break; // Strings' subsets before digit do not match
|
||||||
|
|
||||||
|
|
||||||
bool second_digit = false;
|
|
||||||
if (left.size() > posL + 1)
|
|
||||||
second_digit = left.at(posL + 1).isDigit();
|
|
||||||
if (right.size() > posR + 1)
|
|
||||||
second_digit = second_digit ?
|
|
||||||
second_digit :
|
|
||||||
right.at(posR + 1).isDigit();
|
|
||||||
|
|
||||||
if (!second_digit)
|
|
||||||
break; // Single digit in both, normal sort could handle this
|
|
||||||
|
|
||||||
QString temp;
|
QString temp;
|
||||||
while (posL < left.size()) {
|
while (posL < left.size()) {
|
||||||
if (left.at(posL).isDigit())
|
if (left.at(posL).isDigit())
|
||||||
@ -577,7 +565,6 @@ bool misc::naturalSort(QString left, QString right, bool &result) { // uses less
|
|||||||
// Do another round
|
// Do another round
|
||||||
left.remove(0, posL);
|
left.remove(0, posL);
|
||||||
right.remove(0, posR);
|
right.remove(0, posR);
|
||||||
continue;
|
|
||||||
|
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user