Vectorized searchsorted numpy
<p>Assume that I have two arrays <code>A</code> and <code>B</code>, where both <code>A</code> and <code>B</code> are <code>m x n</code>. My goal is now, for each row of <code>A</code> and <code>B</code>, to find where I should insert the elements of row <code>i</code> of <code>A</code> in the corresponding row of <code>B</code>. That is, I wish to apply <code>np.digitize</code> or <code>np.searchsorted</code> to each row of <code>A</code> and <code>B</code>.</p>

<p>My naive solution is to simply iterate over the rows. However, this is far too slow for my application. My question is therefore: is there a vectorized implementation of either algorithm that I haven't managed to find?</p>