title: Using bsearch to find index for inserting new element into sorted array
body: <p>I have a sorted unique array and want to efficiently insert an element into it that is not in the array like this:</p>
  
  <pre><code>a = [1,2,4,5,6]
  new_elm = 3
  insert_at = a.bsearch_index {|x| x &gt; new_elm } # =&gt; 2
  a.insert(insert_at, new_elm) # now a = [1,2,3,4,5,6]
  </code></pre>
  
  <p>The method <code>bsearch_index</code> doesn't exist: only <code>bsearch</code>, which returns the matching element rather than the matching element's index. Is there any built in way to accomplish this?</p>