Bug 411707 - Natural sorting doesn't handle numbers with decimal points
Summary: Natural sorting doesn't handle numbers with decimal points
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: view-engine: general (other bugs)
Version First Reported In: 19.08.1
Platform: Arch Linux Linux
: NOR minor
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
: 444344 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-09-08 11:41 UTC by Kishore Gopalakrishnan
Modified: 2026-04-02 14:18 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Screenshot showing Dolphin's wrong sorting order. (15.46 KB, image/png)
2019-09-08 11:41 UTC, Kishore Gopalakrishnan
Details
Screenshot showing the issue (17.70 KB, image/png)
2019-09-08 11:48 UTC, Kishore Gopalakrishnan
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kishore Gopalakrishnan 2019-09-08 11:41:11 UTC
Created attachment 122532 [details]
Screenshot showing Dolphin's wrong sorting order.

SUMMARY
Natural sorting does not sort numbers with decimal points as per their numerical value.

STEPS TO REPRODUCE
1. Create files whose names have numbers with decimal points.
2. Enable natural sorting in Settings > Dolphin > General


OBSERVED RESULT
Digits after the decimal point are just compared digit-by digit for sorting purposes (Attached screenshot).

EXPECTED RESULT
Numbers with decimal points should also be sorted according to their numerical value if natural sorting is enabled. For example, the 'ls' program does this correctly.

SOFTWARE/OS VERSIONS
Linux distro: Arch Linux
KDE Plasma Version: 5.16.5
KDE Frameworks Version: 5.61.0
Qt Version: 5.13.0

ADDITIONAL INFORMATION
Also happens with folders.
Comment 1 Kishore Gopalakrishnan 2019-09-08 11:47:07 UTC
Oh sorry, what I meant in the 'observed behaviour' part is that it seems to discard the leading zeroes after the decimal point and start the comparison anew. It is not comparing them digit by digit.
Comment 2 Kishore Gopalakrishnan 2019-09-08 11:48:40 UTC
Created attachment 122533 [details]
Screenshot showing the issue

This screenshot shows the issue more clearly.
Comment 3 aristsakas 2025-12-25 20:50:04 UTC
*** Bug 444344 has been marked as a duplicate of this bug. ***
Comment 4 Akseli Lahtinen 2026-02-16 11:57:52 UTC
Looks like this is still an issue

Operating System: KDE Linux 2026-02-16
KDE Plasma Version: 6.6.80
KDE Frameworks Version: 6.24.0
Qt Version: 6.10.2
Kernel Version: 6.18.9-zen1-2-zen (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen 5 3600 6-Core Processor
Memory: 16 GiB of RAM (15.5 GiB usable)
Graphics Processor: AMD Radeon RX 6600
Comment 5 Bug Janitor Service 2026-03-23 03:01:39 UTC
A possibly relevant merge request was started @ https://invent.kde.org/system/dolphin/-/merge_requests/1229
Comment 6 Méven 2026-04-02 14:18:34 UTC
Git commit 0d10eff3726e5de60298452308cc4b2b7820e10b by Méven Car, on behalf of Pan Zhang.
Committed on 02/04/2026 at 14:17.
Pushed by meven into branch 'master'.

kfileitemmodel: sort dotted numeric names naturally

Natural sorting already handled plain numeric chunks, but names containing dots between numeric segments were still ordered lexically in important cases. This broke expected ordering for decimal-style names like 0.09 and 0.1, and for version-like names such as v1.2.3 and v1.2.10.

Teach KFileItemModel's natural string comparison to recognize dotted numeric chains instead of relying solely on QCollator's numeric mode. Compare two-part numeric chains (e.g. 0.09 vs 0.1) as decimal values, and compare longer chains segment by segment like version numbers, while still treating real file extensions separately so names like 1.09.txt keep working correctly.

Add a direct unit test for KFileItemModel::stringCompare covering decimal-style names, version-like dotted numeric names, numeric basenames with extensions, leading-dot names, and the non-natural sorting fallback.

M  +232  -13   src/kitemviews/kfileitemmodel.cpp
M  +37   -0    src/tests/kfileitemmodeltest.cpp

https://invent.kde.org/system/dolphin/-/commit/0d10eff3726e5de60298452308cc4b2b7820e10b