-
Notifications
You must be signed in to change notification settings - Fork 322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sorting behaves really weird #942
Comments
That's a quirk of natural sorting. You can get lexicographical sorting with |
Never heard of that, but how does that explain stuff like the order of:
It's not even sorted properly; it's just inconsistent. This doesn't seem to be the result of "multi-digit numbers are treated atomically, i.e., as if they were a single character." Also: |
It does look like the natural sort here is not up to spec. I checked with a C implementation I had lying around and the order is
|
Just checked and lf sorts these files as your C implementation. I'm on a different platform, though: Arch Linux |
I think the comparison function |
Sorry for going off-topic but I found it interesting that natural sort in the C implementation above seem to be treating 0s as something with value. In that I guess it's kind of logical in the sense that
From the description by Wikipedia (I have yet to read an actual spec for natural sort, couldn't find one), I would expect it to sort like:
|
@sagehane They are actually sorted as
which seems odd. I checked the implementation (taken from https://github.com/sourcefrog/natsort/blob/master/strnatcmp.c) and while it mentions it is skipping leading zeroes, it doesn't actually do it. Some things a natural sort could handle are listed here: https://rosettacode.org/wiki/Natural_sorting |
Welp, I find it inconsistent that the C implementation would presumably sort something like:
I guess the takeaway is that natural sorting is hard to implement. |
Notes:
lf
version:Platform:
I have
LC_COLLATE
set toC
.Expected/Desired Behaviour:
Ideally,
lf
should probably sort things similarly tosort
by respecting system locale, or at least just sort in a sensible manner.For example, I would expect
lf
to sort the files in a directory similarly to whatsort
does:Actual Behaviour:
lf
currently sorts this directory in the following order:I don't see why
000
should be listed before0
but after00
.For clarity, all the files were created with
touch
and they shouldn't be directories or have some properties that affect their order other than their names.The text was updated successfully, but these errors were encountered: