@@ -108,8 +108,8 @@ import { idof } from "./builtins";
108108 @operator ( ">" ) private static __gt ( left : String | null , right : String | null ) : bool {
109109 if ( left === right || left === null || right === null ) return false ;
110110 var leftLength = left . length ;
111+ if ( ! leftLength ) return false ;
111112 var rightLength = right . length ;
112- if ( ! leftLength ) return false ;
113113 if ( ! rightLength ) return true ;
114114 // @ts -ignore: string <-> String
115115 return compareImpl ( left , 0 , right , 0 , min ( leftLength , rightLength ) ) > 0 ;
@@ -121,10 +121,10 @@ import { idof } from "./builtins";
121121
122122 @operator ( "<" ) private static __lt ( left : String , right : String ) : bool {
123123 if ( left === right || left === null || right === null ) return false ;
124- var leftLength = left . length ;
125124 var rightLength = right . length ;
126125 if ( ! rightLength ) return false ;
127- if ( ! leftLength ) return true ;
126+ var leftLength = left . length ;
127+ if ( ! leftLength ) return true ;
128128 // @ts -ignore: string <-> String
129129 return compareImpl ( left , 0 , right , 0 , min ( leftLength , rightLength ) ) < 0 ;
130130 }
@@ -163,6 +163,17 @@ import { idof } from "./builtins";
163163 return - 1 ;
164164 }
165165
166+ // TODO: implement full locale comparison with locales and Collator options
167+ localeCompare ( other : String ) : i32 {
168+ if ( other === this ) return 0 ; // compare pointers
169+ var len : isize = this . length ;
170+ var otherLen : isize = other . length ;
171+ if ( otherLen != len ) return select ( 1 , - 1 , len > otherLen ) ;
172+ if ( ! otherLen ) return 0 ; // "" == ""
173+ // @ts -ignore: string <-> String
174+ return compareImpl ( this , 0 , other , 0 , otherLen ) ;
175+ }
176+
166177 startsWith ( search : String , start : i32 = 0 ) : bool {
167178 if ( search === null ) search = changetype < String > ( "null" ) ;
168179 var len = < isize > this . length ;
0 commit comments