Ruby/Bsearch is a binary search library for Ruby. It can search the FIRST or LAST occurrence in an array with a condition given by a block. The latest version of Ruby/Bsearch is available at <URL:/ruby-bsearch/> . Example % irb -r ./bsearch.rb >> %w(a b c c c d e f).bsearch_first {|x| x <=> "c"} => 2 >> %w(a b c c c d e f).bsearch_last {|x| x <=> "c"} => 4 >> %w(a b c c c d e f).bsearch_upper_boun