From 5437974b85095780bb6a97fa76bc0e618f4a5b42 Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Thu, 21 Dec 2017 15:01:13 +0200 Subject: [PATCH] Fix natural sorting when the common part of 2 strings ends partially in a number which continues in the uncommon part. Closes #8080 #6732. --- src/base/utils/string.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/base/utils/string.cpp b/src/base/utils/string.cpp index a7a58edf5..c2a592b9c 100644 --- a/src/base/utils/string.cpp +++ b/src/base/utils/string.cpp @@ -85,7 +85,10 @@ namespace const QChar leftChar = (m_caseSensitivity == Qt::CaseSensitive) ? left[posL] : left[posL].toLower(); const QChar rightChar = (m_caseSensitivity == Qt::CaseSensitive) ? right[posR] : right[posR].toLower(); - if (leftChar == rightChar) { + // Compare only non-digits. + // Numbers should be compared as a whole + // otherwise the string->int conversion can yield a wrong value + if ((leftChar == rightChar) && !leftChar.isDigit()) { // compare next character ++posL; ++posR;