![]() Registered Member ![]()
|
Distribution: Kubuntu 10.10
KDE version: 4.5.5 Hi. I am wondering if someone can educate me on "natural sorting" in Dolphin. It is turned on by default, with which my three files are listed as below.
My question is, how is it "natural" when "receipts_20110405.jpeg" is listed before "receipts_2011010203.jpeg"? Of course, turning natural sorting off will correctly reverse the order of those two files, but even with natural sorting on, I would expect "receipts_2011010203.jpeg" to be listed before "receipts_20110405.jpeg." Can someone enlighten me on that? Thanks...
Last edited by daihard on Sun Jun 05, 2011 6:19 pm, edited 1 time in total.
Kubuntu 12.04 (Precise Pangolin) 64-bit / KDE 4.8.1
Work: Dell Precision T5500 (Xeon E5506 @ 2.13 GHz x 2 / 12GB RAM) Home: Panasonic Toughbook W8 (Core 2 Duo @ 1.20 GHz / 4GB RAM) |
![]() Manager ![]()
|
from the handbook http://docs.kde.org/stable/en/kdebase-a ... lphin.html
my reading of it is that Dolphin looks at the numbers after "receipts_" and compares their numerical values and as 2011010203 is > 20110405 it is placed last in the sort order |
![]() Registered Member ![]()
|
google is right. Natural sorting, pretty much by definition, treats a series of numerical characters as a single multi-digit number.
So for normal sorting, 100 is treated as a series of three characters, 1, then 0, then 0. For natural sorting, it is treated as a single number, "100". So when you compare 20 to 100 the standard way, it compares the first characters 1 and 2, and decides the character 2 is larger. That is all it needs to make a decision. With natural sorting, it compares the numbers 20 and 100 and decides the number 100 is larger. You could think of it as though the number was being treated as a single character with a very large value.
Man is the lowest-cost, 150-pound, nonlinear, all-purpose computer system which can be mass-produced by unskilled labor.
-NASA in 1965 |
![]() Registered Member ![]()
|
Aah, I got it. Thanks guys. Since I named those files after the year and month(s) they were related to, it never occurred to me that "2011010203" could be considered a whole number.
With all that in mind, I believe turning natural sorting off will be the better option for me. strcmp() all the way. ![]()
Kubuntu 12.04 (Precise Pangolin) 64-bit / KDE 4.8.1
Work: Dell Precision T5500 (Xeon E5506 @ 2.13 GHz x 2 / 12GB RAM) Home: Panasonic Toughbook W8 (Core 2 Duo @ 1.20 GHz / 4GB RAM) |
![]() Registered Member ![]()
|
If you put dashes in (or some other character) it will sort properly.
So for instance: pf_bus_2011-01-02-03.pdf receipts_2011-04-05.jpeg receipts_2011-01-02-03.jpeg
Man is the lowest-cost, 150-pound, nonlinear, all-purpose computer system which can be mass-produced by unskilled labor.
-NASA in 1965 |
Registered users: Bing [Bot], Google [Bot], Sogou [Bot], Yahoo [Bot]