File sorting issue in Dolphin and Gwenview

Hi guys,

I recently noticed the file name sorting issue in Dolphin and Gwenview. I am currently using KDE Applications 20.04.1 in openSUSE Tumbleweed snapshot 20200526.

For me, neither Natural sorting nor Alphabetical sorting could give me the right (to me) order of sorting. For example, I create a series of files in a folder and sort them,

for ((i=0;i<101;i++)) ; do touch $i.jpg ; done

The files are always sorted as,

0.jpg
1.jpg
10.jpg
100.jpg
11.jpg
12.jpg
...

It is the same as the sorting in Konsole using ls -1, as well as when viewing the folder or browsing by Left/Right Arrow keys in Gwenview.

Do you guys have this problem? Or, it’s just because of my wrong settings?

I also noticed that the Dolphin will not change sorting order after change of setting unless a new instance of Dolphin is started.

I have read a post by wolfi323 on 16-Feb-2017, saying the patch had not been accepted. But I see that the bug has been fixed in Framework 5.34. Then, I am confused.

If there is nothing wrong with sorting feature in KDE, how should I do to solve the issues?

Thanks in advance.

zz

Ǐ’m not sure why you think that a problem.

The sort order that you report seems correct. That’s the collating sequence order for ASCII characters.

I thought the right order should be,

0.jpg
1.jpg
2.jpg
3.jpg
...
9.jpg
10.jpg
11.jpg
12.jpg
...

Is this the natural sorting?

Hi
The command ls -v, ls -lv etc will work in a terminal running bash…

Thanks. That indeed gives file list in natural order in terminal. But how to make natural sorting work for Dolphin and Gwenview?

Hi
I use GNOME (Nautilus) which uses natural sorting, but it should be configurable according to https://docs.kde.org/stable5/en/applications/dolphin/configuring-dolphin.html

I knew the settings but it actually did not work. So I asked here.

Hi
Then I would assume the bug is not fixed… You could try creating a test user, login and see if it duplicates?

Restart Dolphin after changing to use Natual sorting mode.

FTR, I just ran this code from the first post:

for ((i=0;i<101;i++)) ; do touch $i.jpg ; done

Then opened the folder in dolphin, and the order was as I would expect with natural sorting, i.e. 0.jpg, 1.jpg, … , 100.jpeg.

What locale are you using?
I.e. what’s the output of running “locale” in konsole inside your user session?

Hi, sorry for not replying sooner.

Good suggestion. And I found another weird thing: I cannot correctly create a new user. I created a new user test, then I found I cannot login with it. It’s uid is 3. Then I created another one ztest and got this,

cnzhx@ostp:~> id ztest
id: ‘ztest’: no such user

I cannot figure out the problem. Maybe I should reinstall the OS later when I finish stuff in hand.

Thanks. I restarted Dolphin, even the OS, but Dolphin still cannot sort the files naturally.

Then you confirmed the bug was fixed and the problem might only be with my system. The output is,

cnzhx@ostp:~> locale
LANG=en_GB.UTF-8
LC_CTYPE=en_GB.UTF-8
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE=C
LC_MONETARY=C
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT=C
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=

It seems normal to me.

By default only ids 1000…60000 can login. Check out in Login Screen (SDDM), Advanced settings. You can change the user id for an user:

sudo usermod -u 1010 test

It shouldn’t require restarting Dolphin, but it only worked for me when I did that (LANG is en_US.UTF-8). That’s still an issue, but yet it can work. Try with the new user again.

Yes, changing uid corrected the login issue. Wonderfully, the natural sorting in the new user works as promised. Do you happen to know how to fix it for my normal user? It’s better not to reinstall the OS lol!

Regarding the issue of new user creation, I guess I was hit by the change to /etc/nsswitch.conf according a search result from here. Here is the content of my /etc/nsswitch.conf file,

passwd:         compat
group:          compat
shadow:         compat

hosts:          files dns
networks:       files dns

aliases:        files usrfiles
ethers:         files usrfiles
gshadow:        files usrfiles
netgroup:       files nis
protocols:      files usrfiles
publickey:      files
rpc:            files usrfiles
services:       files usrfiles

automount:      files nis
bootparams:     files
netmasks:       files

Is there anything wrong?

Ok, got it. Just as wolfi323 suggested, the issue is caused by locale settings. In order to use SI units, I changed LC_COLLATE, LC_MONETARY and LC_MEASUREMENT in System Settings > Regional Settings. After changing them back to language default, the natural sorting works like a charm.

Thank you guys for your help on solving my issue :slight_smile:

The issue it’s a different one, from another distro.

The new user id is governed by UID_MIN…UID_MAX settings in a login.defs file:

grep UID_ {/usr,}/etc/login.defs

Maybe you have something wrong in the /etc file. I only have the file in /usr/etc.

It might be a good time to run this:

sudo rpmconfigcheck

You may have missed an upgrade conflict.

I got this,

ostp:~ # grep UID_ {/usr,}/etc/login.defs
/usr/etc/login.defs:# No LASTLOG_UID_MAX means that there is no user ID limit for writing
/usr/etc/login.defs:#LASTLOG_UID_MAX
/usr/etc/login.defs:# No LASTLOG_UID_MAX means that there is no user ID limit for writing
/usr/etc/login.defs:#LASTLOG_UID_MAX
/usr/etc/login.defs:# SYS_UID_MIN to SYS_UID_MAX inclusive is the range for
/usr/etc/login.defs:# UID_MIN to UID_MAX inclusive is the range of UIDs of dynamically
/usr/etc/login.defs:UID_MIN                      1000
/usr/etc/login.defs:UID_MAX                     60000
/usr/etc/login.defs:SYS_UID_MIN           100
/usr/etc/login.defs:SYS_UID_MAX           499
/usr/etc/login.defs:SUB_UID_MIN            100000
/usr/etc/login.defs:SUB_UID_MAX         600100000
/usr/etc/login.defs:SUB_UID_COUNT                   65536
/etc/login.defs:UID_MAX "0"
/etc/login.defs:UID_MIN "0"
ostp:~ # rpmconfigcheck
Searching for unresolved configuration files

I have /etc/login.defs. It looks like this file should be removed in previous upgrade but did not.

And I have /etc/nsswitch.conf and /usr/etc/nsswitch.conf, both of which have the same content.

I have always run rpmconfigcheck after an upgrade and manually updated config files accordingly. Maybe I missed something in the processes.

The content of /etc/login.defs file looks not right,

cnzhx@ostp:~> cat /etc/login.defs
FAIL_DELAY      "0"
GID_MAX "0"
GID_MIN "0"
PASS_MAX_DAYS   "0"
PASS_MIN_DAYS   "0"
PASS_WARN_AGE   "0"
UID_MAX "0"
UID_MIN "0"

I rename this file and restart. Now, the creation of a new user works well.

Thank you all for the help lol!