Bug 470538 - Possible file sorting issue
Summary: Possible file sorting issue
Status: RESOLVED FIXED
Alias: None
Product: dolphin
Classification: Applications
Component: view-engine: general (show other bugs)
Version: 23.04.1
Platform: Other Linux
: NOR minor
Target Milestone: ---
Assignee: Dolphin Bug Assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-01 20:16 UTC by advice2020
Modified: 2024-11-19 09:08 UTC (History)
2 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description advice2020 2023-06-01 20:16:55 UTC
SUMMARY
Have noticed what I believe is a file sorting issue in Plasma / Dolphin.
Happens when using " - "  patterns which can be seen in examples below.
When testing this out it seems like common practice by other Linux desktop environments as well as in Windows all seem to sort this way which is why I believe it could be viewed as an issue in Plasma / Dolphin.

OBSERVED RESULT
If filenames do not have an extension they will sort like the following…
FRUIT
FRUIT – Apple
FRUIT – Grape
which makes sense, does the same as "expected result"

However in Plasma, if filenames include an extension, then they sort like the following…
FRUIT – Apple.txt
FRUIT – Grape.txt
FRUIT.txt

EXPECTED RESULT
FRUIT.txt
FRUIT – Apple.txt
FRUIT – Grape.txt


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 
KDE Plasma Version: 5.20.5
KDE Frameworks Version: 5.78.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Comment 1 Nate Graham 2023-06-05 17:29:43 UTC
Can confirm.

But note that Dolphin and Plasma use different sorting systems. Let's use this bug report for Dolphin. Can you please submit a new one for Plasma? And I assume by "Plasma" you mean "Icons on the desktop or a Folder View widget? Or something else?
Comment 2 advice2020 2023-06-06 21:40:47 UTC
@Nate Graham
Thank you for your response and for confirming.
No problem I can make that submit for Plasma as well but before I do I just want to get on the same page because I was not aware of the fact that two different sorting systems are applied, although makes sense because Dolphin does have a sort option in settings.
Anyways when I refer to Plasma, the items you mention are included but also what about things like the "open" and "save as" windows that Plasma uses for programs?  Although they have a similar look to Dolphin, I was assuming these were part of Plasma itself, do you know where those are coming from?
I will wait for an answer from you or other members before I make that submit so I can include that information.

A quick side note, I imagine you are quite busy but maybe you would be able to answer this question about sorting I posted here
https://discuss.kde.org/t/how-does-plasma-achieve-natural-sorting-of-files/1807
Only reason I am asking you is that you mentioned / knew about the fact that two sorting systems were being used, figured maybe you might know the answer.
Thanks again for taking the time to confirm my findings.
Comment 3 Nate Graham 2023-06-07 17:56:12 UTC
Open and Save As dialogs are provided by still another thing: KIO. All of them use different code, so they would all need to be separately changed. Make sure to relate the bug reports you submit using the "see also" field.

I don't know how to fix it, sorry.
Comment 4 Bug Janitor Service 2024-11-17 16:14:51 UTC
A possibly relevant merge request was started @ https://invent.kde.org/system/dolphin/-/merge_requests/858
Comment 5 Méven 2024-11-19 09:08:49 UTC
Git commit e4cc6e69430049366434e3383b1d2ef283ed22cc by Méven Car, on behalf of Eren Karakas.
Committed on 19/11/2024 at 09:08.
Pushed by meven into branch 'master'.

natural sort: exclude extension when comparing filenames

Currently natural sort compares the entire filenames
(basename.extension) when sorting. This causes eg.
"a 2.txt" to appear before "a.txt" when sorted by ascending.
This is unintuitive since people prioritize basenames more
than file extensions.

Instead, change natural sort to compare by basename only and
fallback to comparing extensions if basenames were equal.
This change causes "a.txt" to appear before "a 2.txt" and
matches how other platforms such as GNOME and Windows behave.
Related: bug 416025, bug 421869, bug 312027

M  +18   -1    src/kitemviews/kfileitemmodel.cpp
M  +8    -2    src/kitemviews/kfileitemmodel.h
M  +78   -0    src/tests/kfileitemmodeltest.cpp

https://invent.kde.org/system/dolphin/-/commit/e4cc6e69430049366434e3383b1d2ef283ed22cc