Refactoring `array.index()` to be a binary search