I am looking for a built-in Ruby method that has the same functionality as index but uses a binary search algorithm, and thus requires a pre-sorted array.
I use bsearch. This is how it works:
array = ['one', 'two', 'three', 'four', 'five']
search = array.sort.bsearch { |value| 'four' <=> value }
Note: binary search needs a sorted array; this adds a li'l overhead but it's fine, compared to the speed of the search.
search will return the value four of the array, else nil if it doesn't find the value.