binary-search

Optimum way to compare strings in JavaScript? [duplicate]

拜拜、爱过 提交于 2019-11-26 02:16:22
问题 This question already has answers here : Is there a JavaScript strcmp()? (5 answers) Closed 6 years ago . I am trying to optimize a function which does binary search of strings in JavaScript. Binary search requires you to know whether the key is == the pivot or < the pivot. But this requires two string comparisons in JavaScript, unlike in C like languages which have the strcmp() function that returns three values (-1, 0, +1) for (less than, equal, greater than). Is there such a native