-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
fix: use Intl.Collator for string sorting when available #3809
Conversation
0c7fb02
to
1578490
Compare
lib/outdated.js
Outdated
@@ -85,7 +86,7 @@ class Outdated extends ArboristWorkspaceCmd { | |||
})) | |||
|
|||
// sorts list alphabetically | |||
const outdated = this.list.sort((a, b) => a.name.localeCompare(b.name, 'en')) | |||
const outdated = this.list.sort(({ name: a }, { name: b }) => localeCompare(a, b) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const outdated = this.list.sort(({ name: a }, { name: b }) => localeCompare(a, b) | |
const outdated = this.list.sort(({ name: a }, { name: b }) => localeCompare(a, b)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ha, fixed that one locally, but neglected to add it to my amended commit. Thanks.
351b2fb
to
7b0cd12
Compare
@@ -15,8 +16,7 @@ const installedDeep = async (npm) => { | |||
return i | |||
}) | |||
.filter(i => (i.depth - 1) <= depth) | |||
.sort((a, b) => a.depth - b.depth) | |||
.sort((a, b) => a.depth === b.depth ? a.name.localeCompare(b.name, 'en') : 0) | |||
.sort((a, b) => (a.depth - b.depth) || localeCompare(a.name, b.name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bonus! Lots of little improvements to all these sort functions.
The npm/cli form of npm/arborist#324 Required adding options support to package used for this. PR-URL: #3809 Credit: @isaacs Close: #3809 Reviewed-by: @wraithgar
7b0cd12
to
dbb90f7
Compare
Yeah, that double-sort on installedDeep was a bit of a head-scratcher. |
The npm/cli form of npm/arborist#324
Required adding options support to package used for this.
References