function binarySearch(value) { var startIndex = 0, stopIndex = words.length - 1, middle = Math.floor((stopIndex + startIndex) / 2); while (w
The best way is to use trees instead, since for an array such an operation is likely to have linear algorithmic complexity.
If you'd like to stick with the arrays, I suggest that you use the splice method for insertion.