Ticket #1860 (closed defect: fixed)
Unwanted natural sorting of numbers in file panels
|Reported by:||Wiseman1024||Owned by:||andrew_b|
|Keywords:||sort order collation numeric numbers||Cc:|
|Branch state:||Votes for changeset:|
I've noticed when Midnight Commander sorts filenames alphabetically, it treats numbers specially as to sort filenames "a1", "a3" and "a20" in this order, contrary to the expected "a1", "a20", "a3" order provided by most if not everything else (examples I had readily available: ls, sort, Konqueror file manager, KDE file chooser, Opera's file chooser, Python's sorted(os.listdir('.'))). As a reference, FAR Manager sorts like everything else too. It's just Midnight Commander the one sorting weirdly.
While this may look nice on the basis that the number 3 comes before the number 20 and so on (when treated as such!), this is extremely irritating because almost everything else will sort files correctly and contradict Midnight Commander's file sorting. It's even dangerous, as it may lead to user confusion and mistakes that could derive in data loss. Allow me to explain my particular case as an example: I use Midnight Commander as my central file management tool. However, in order to view image files, I've associated my own image viewer with the F3 (view) action for image files. This image viewer allows me to walk forwards and backwards within the directory starting from the file I used to open it, so for example I'm in a directory with files "a1.png", "a3.png" and "a20.png" as seen in Midnight Commander. I hit F3 on "a1.png", and then go forwards to the next file expecting to view what was next in Midnight Commander - "a3.png"; however the image viewer (and any other application I have) will jump to "a20.png" if they're alphabetically sorting files. I may then see something I don't like, and decide to delete the next file to the one I started browsing, so when I'm back to Midnight Commander I go and delete the wrong file ("a3.png").
I'm experiencing this problem in both Debian sid on i686 and Ubuntu Hardy on AMD64, with both Midnight Commander 4.7.0-pre1-3 from the Debian sid repository and Midnight Commander 4.7.0-pre4 compiled from source. Both systems are similar in setup. Here's information for one of them:
# uname -a
Linux Zohar 2.6.31-1-686 #1 SMP Sun Nov 15 20:39:33 UTC 2009 i686 GNU/Linux
# cat /etc/issue
Debian GNU/Linux squeeze/sid \n \l
# dpkg -l mc libglib2.0-0 libslang2 | tail -3
ii libglib2.0-0 2.22.2-2 The GLib library of C routines
ii libslang2 2.2.1-1 The S-Lang programming library - runtime version
ii mc 2:4.7.0-pre1-3 midnight commander - a powerful file manager
I've verified my system's strcoll function orders strings as expected (i.e. strcoll("a10", "a3") returns -1).
- Votes for changeset set to angel_il
- severity changed from no branch to on review
- Votes for changeset angel_il deleted
- severity changed from on review to no branch
comment:10 Changed 6 years ago by andrew_b
- Status changed from accepted to testing
- Resolution set to fixed