File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -134,7 +134,7 @@ namespace ts.NavigationBar {
134
134
function sortNodes ( nodes : Node [ ] ) : Node [ ] {
135
135
return nodes . slice ( 0 ) . sort ( ( n1 : Declaration , n2 : Declaration ) => {
136
136
if ( n1 . name && n2 . name ) {
137
- return getPropertyNameForPropertyNameNode ( n1 . name ) . localeCompare ( getPropertyNameForPropertyNameNode ( n2 . name ) ) ;
137
+ return localeCompareFix ( getPropertyNameForPropertyNameNode ( n1 . name ) , getPropertyNameForPropertyNameNode ( n2 . name ) ) ;
138
138
}
139
139
else if ( n1 . name ) {
140
140
return 1 ;
@@ -146,6 +146,16 @@ namespace ts.NavigationBar {
146
146
return n1 . kind - n2 . kind ;
147
147
}
148
148
} ) ;
149
+
150
+ // node 0.10 treats "a" as greater than "B".
151
+ // For consistency, sort alphabetically, falling back to which is lower-case.
152
+ function localeCompareFix ( a : string , b : string ) {
153
+ const cmp = a . toLowerCase ( ) . localeCompare ( b . toLowerCase ( ) ) ;
154
+ if ( cmp !== 0 )
155
+ return cmp ;
156
+ // Return the *opposite* of the `<` operator, which works the same in node 0.10 and 6.0.
157
+ return a < b ? 1 : a > b ? - 1 : 0 ;
158
+ }
149
159
}
150
160
151
161
function addTopLevelNodes ( nodes : Node [ ] , topLevelNodes : Node [ ] ) : void {
You can’t perform that action at this time.
0 commit comments