Skip to content

Fixing sorting of directory and filenames with numbers - #18539

Merged
Benjamin Pasero (bpasero) merged 2 commits into
microsoft:masterfrom
jchadwick:jchadwick/explorer-sorting-issue
Jan 16, 2017
Merged

Benjamin Pasero (bpasero) merged 2 commits into
microsoft:masterfrom
jchadwick:jchadwick/explorer-sorting-issue

Conversation

@jchadwick

@jchadwick Jess Chadwick (jchadwick) commented Jan 14, 2017 •

Copy link
Copy Markdown
Contributor

These changes replace the existing regex-based sorting of filenames and directory names with a call to the String.prototype.localeCompare() function which supports this natively via the numeric option.

Also added some unit test cases for filenames with numbers.

CC: Benjamin Pasero (@bpasero)

Fixes #17495

@bpasero

Copy link
Copy Markdown
Contributor

Jess Chadwick (@jchadwick) incredible, I was not aware of these options. Thanks for enlighten me 👍

@paror

Copy link
Copy Markdown

I read this on MDN about String.prototype.localeCompare(): When comparing large numbers of strings, such as in sorting large arrays, it is better to create an Intl.Collator object and use the function provided by its compare property.

@jchadwick

Copy link
Copy Markdown
Contributor Author

yeah I saw that too but it wasn't obvious how to do that here. I can take a stab, though.

@jchadwick

Jess Chadwick (jchadwick) commented Jan 14, 2017 •

Copy link
Copy Markdown
Contributor Author

Wow. Intl.Collator is significantly (97%) faster! (And I've switched to it)

@jchadwick
Jess Chadwick (jchadwick) force-pushed the jchadwick/explorer-sorting-issue branch from c02e2ad to afc5448 Compare January 15, 2017 01:57
@paror

Copy link
Copy Markdown

Nice!

@bpasero

Copy link
Copy Markdown
Contributor

LGTM

@jchadwick

Copy link
Copy Markdown
Contributor Author

Hey Benjamin Pasero (@bpasero), just an FYI, this wasn't attributed to me in the 1.9 release notes.

@bpasero

Copy link
Copy Markdown
Contributor

Jess Chadwick (@jchadwick) sorry for that, I wrongly set this PR for February and so it was not picked up by our automated tool that generates release notes for PRs. I will add this, but it might take a day or two until our website gets redeployed.

@bpasero

Copy link
Copy Markdown
Contributor

Added via microsoft/vscode-docs@229ceeb so it should be in the next website update.

@jchadwick

Copy link
Copy Markdown
Contributor Author

Benjamin Pasero (@bpasero) No worries. Thanks!

@jchadwick
Jess Chadwick (jchadwick) deleted the jchadwick/explorer-sorting-issue branch February 3, 2017 19:41
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explorer: Does not sort files and folders with numerical values accordingly

4 participants