Merge two vectors with alternate locations
<p>I have:</p>

<pre><code>import numpy as np
A = np.asarray([1,3,5,7,9])
B = np.asarray([2,4,6,8,10])
</code></pre>

<p>I want to create:</p>

<pre><code>C = np.asarray([1,2,3, 4,5,6,7,8,9,10])
</code></pre>

<p>Is there a better way to do than to run a for loop</p>

<p>Try the following :</p>

<pre><code>import numpy as np
A = np.asarray([1,3,5,7,9])
B = np.asarray([2,4,6,8,10])

C = np.sort(np.hstack((A,B)))
#array([ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10])
</code></pre>

python numpy