File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ export interface TreeNodeOptions extends ResolvedOptions {
12
12
treeNodeOptions ?: TreeNodeValueOptions
13
13
}
14
14
15
+ const stringCompare = new Intl . Collator ( 'en' , { } ) . compare
16
+
15
17
export class TreeNode {
16
18
/**
17
19
* value of the node
@@ -142,24 +144,26 @@ export class TreeNode {
142
144
}
143
145
144
146
/**
145
- * Comparator function for sorting TreeNodes by path.
147
+ * Comparator function for sorting TreeNodes.
148
+ *
149
+ * @internal
146
150
*/
147
- static compareByPath ( a : TreeNode , b : TreeNode ) : number {
148
- return a . path . localeCompare ( b . path )
151
+ static compare ( a : TreeNode , b : TreeNode ) : number {
152
+ return stringCompare ( a . path , b . path )
149
153
}
150
154
151
155
/**
152
156
* Get the children of this node sorted by their path.
153
157
*/
154
158
getSortedChildren ( ) : TreeNode [ ] {
155
- return Array . from ( this . children . values ( ) ) . sort ( TreeNode . compareByPath )
159
+ return Array . from ( this . children . values ( ) ) . sort ( TreeNode . compare )
156
160
}
157
161
158
162
/**
159
163
* Calls {@link getChildrenDeep} and sorts the result by path in the end.
160
164
*/
161
165
getChildrenDeepSorted ( ) : TreeNode [ ] {
162
- return Array . from ( this . getChildrenDeep ( ) ) . sort ( TreeNode . compareByPath )
166
+ return Array . from ( this . getChildrenDeep ( ) ) . sort ( TreeNode . compare )
163
167
}
164
168
165
169
/**
You can’t perform that action at this time.
0 commit comments