-
Notifications
You must be signed in to change notification settings - Fork 29.4k
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
file are not sorted in ascending order for numeric file name #104555
Comments
(Experimental duplicate detection) |
We are fine tuning our sorting. fyi @leilapearson |
Thanks for the report @rajeevbarde Yes, unfortunately numbers with a decimal separator will not always sort numerically. This is expected. There are two things at play here:
(1) is tricky. The reason I say "maybe not good" instead of just "not good" is that the decimal character and thousands separator characters differ by locale and also contextually. For example, a dot in a version number or in an IP address is not a decimal separator - it just separates number groups. I think this is why localeCompare() doesn't bother trying to account for decimal separators and thousands separators in different locales. (2) would be easy enough to change. I could just reverse it so that longer equivalent numbers come first instead of last. I thought it was nicer to sort shorter equivalent numbers first - and more consistent with - for example - sorting a < aa < aaa. It is probably more common to sort them last though. The simple change for (2) would resolve the specific cases in this report but if you expand the cases a bit you'll still see |
@leilapearson I want to report another sorting issue here. Let me know if I should create a new bug for this. For a case where 2 filenames have the same prefix and 1 of them doesn't have any suffix at all, the file without the suffix should be sorted ahead of the one with a suffix. A file named Take a look at the following example. |
Hi @ronakg. The reason this happens is that vscode sorts in locale order but bash shorts in unicode order. Locale order sorts the underscore character before the dot character, but unicode order does the opposite. I submitted a PR that adds the option for vscode to sort in unicode order - as well as options to sort in locale order but group by uppercase first or lowercase first. That PR is currently on hold though as the maintainers evaluate the level of demand for these new settings. See PR #97272 for more detail. Issue #99955 also provides a lot more background if you're interested. |
@leilapearson that option would be nice. Thanks for the info. |
This is what happened for me with Sort Order = default 9658.. < 09765.. < 9778... < 12705... and so on
|
@fastrde Hex numbers aren't going to sort so nicely unfortunately... The default sort will sort numerically - ignoring leading zeros - and considering the number to be complete once it reaches anything non-numeric... The PR I mentioned above would provide a unicode sorting option that might give you what you are looking for... not a nice hex sort, but at least a character by character comparison sort. |
@leilapearson I'm looking for what is described as the default sorting in VSCode. I don't want to sort hex numbers by value. I don't want to sort numbers by value either. I want to sort alphabetical. That's all :-). The description of sort order default is Files and folders are sorted by their names, in alphabetical order. Folders are displayed before files. default sorting at the moment
Sorting I expected when I read the description
|
@fastrde that makes sense. Unfortunately the text is misleading. The actual behavior - since way before I got involved - has been to do a I did submit an earlier pull request that provided the ability to do the various sort options with the numeric option turned off, but it didn't seem like many people were asking for that option and the maintainers requested a less complicated PR so I withdrew it. If enough people want a locale-based alphabetical comparison that doesn't have numeric sorting enabled - and the maintainers agree - then that feature could certainly be added at a later date. |
Also, I'm happy to submit a new PR to add that new "non-numeric" option if the maintainers give the go ahead. |
A "non-numeric" option would be very useful; I was bitten by this too, in the same scenario as @fastrde (a directory with many files containing hex hashes in their name). |
@leilapearson was waiting for the go-ahead to submit a PR adding a "non-numeric" file sort option.
@isidorn I hope maintainers can reconsider this, I believe it is in the scope of VSCode |
I am discussing a potential PR with @leilapearson on another issue, once we tackle that we might look into this. |
Hi @isidorn :) Wondering if there is a decision on the PR you mentioned above? Could you re-open this issue? |
@Leedehai the PR he was referring to was merged earlier this month and is currently available in VS Code Insiders builds and should be in the next VS Code release which I think is due out pretty soon. It doesn't directly address this issue, but there is a unicode option which is a non-numeric sort which will perhaps meet your needs? If you have a chance to try it, let us know what you think. |
On VS Explorer, the file is not sorted in ascending order as shown below, (compared with Window Explorer)
Does this issue occur when all extensions are disabled?: Yes
The text was updated successfully, but these errors were encountered: