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 @@ -140,7 +140,7 @@ namespace ts.NavigationBar {
140140 function sortNodes ( nodes : Node [ ] ) : Node [ ] {
141141 return nodes . slice ( 0 ) . sort ( ( n1 : Declaration , n2 : Declaration ) => {
142142 if ( n1 . name && n2 . name ) {
143- return getPropertyNameForPropertyNameNode ( n1 . name ) . localeCompare ( getPropertyNameForPropertyNameNode ( n2 . name ) ) ;
143+ return localeCompareFix ( getPropertyNameForPropertyNameNode ( n1 . name ) , getPropertyNameForPropertyNameNode ( n2 . name ) ) ;
144144 }
145145 else if ( n1 . name ) {
146146 return 1 ;
@@ -152,6 +152,16 @@ namespace ts.NavigationBar {
152152 return n1 . kind - n2 . kind ;
153153 }
154154 } ) ;
155+
156+ // node 0.10 treats "a" as greater than "B".
157+ // For consistency, sort alphabetically, falling back to which is lower-case.
158+ function localeCompareFix ( a : string , b : string ) {
159+ const cmp = a . toLowerCase ( ) . localeCompare ( b . toLowerCase ( ) ) ;
160+ if ( cmp !== 0 )
161+ return cmp ;
162+ // Return the *opposite* of the `<` operator, which works the same in node 0.10 and 6.0.
163+ return a < b ? 1 : a > b ? - 1 : 0 ;
164+ }
155165 }
156166
157167 function addTopLevelNodes ( nodes : Node [ ] , topLevelNodes : Node [ ] ) : void {
You can’t perform that action at this time.
0 commit comments