Details
-
Bug
-
Resolution: Duplicate
-
P3: Somewhat important
-
None
-
5.15.2, 6.7.2
-
None
Description
On Windows calling QCollator::sortKey gives a QCollatorSortKey that results in wrong sorting of numbers. Specifically the numbers 0-9 get sorted into alphabetical characters like A, 0, B, C, 1, D, 2, 3, 4, E, 5, F, 6, G, 7, 8, 9, H, I, ....
This Python code demonstrates the issue:
from PySide6.QtCore import QCollator, QLocale locale = QLocale('en') collator = QCollator(locale) print(collator.sortKey('A') < collator.sortKey('C')) # prints True, as expected print(collator.sortKey('1') < collator.sortKey('C')) # prints False, expected is True print(collator.sortKey('1') < collator.sortKey('D')) # 1 sorts between C and D
The issue is reproducible on both Qt 5.15.2 and Qt 6.7.2. This only happens on Windows, on Linux and macOS the sorting seems fine.
Using collator.compare works as expected, collator.compare('1', 'A') correctly returns -1. But this is not a workaround for all use cases.
Using collator.setNumericMode(True) also results in proper sorting of single digits and alphabetical characters, but as described in QTBUG-108756 this also has issues.
Attachments
Issue Links
- duplicates
-
QTBUG-88704 QCollatorSortKey is not working properly without ICU support
- In Progress
- relates to
-
QTBUG-88704 QCollatorSortKey is not working properly without ICU support
- In Progress