<p dir="auto">i.e:<br>
a=[2,0,-1,3]<br>
np.argsort(a)<br>
output is right:<br>
array([2, 1, 0, 3], dtype=int64)</p>
<p dir="auto">but:<br>
a=[2,-1,0,3]<br>
np.argsort(a)<br>
output has soemthing wrong:<br>
array([1, 2, 0, 3], dtype=int64)<br>
The correct outpus should be:<br>
array([2, 0, 1, 3], dtype=int64)</p>
<p dir="auto">Something very strange happens when you try adding a transposed array to itself:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; import numpy as np
&gt;&gt;&gt; arr = np.ones((100, 100))
&gt;&gt;&gt; arr+=arr.T
&gt;&gt;&gt; arr
array([[ 2.,  2.,  2., ...,  2.,  2.,  2.],
       [ 2.,  2.,  2., ...,  2.,  2.,  2.],
       [ 2.,  2.,  2., ...,  2.,  2.,  2.],
       ..., 
       [ 3.,  3.,  3., ...,  2.,  2.,  2.],
       [ 3.,  3.,  3., ...,  2.,  2.,  2.],
       [ 3.,  3.,  3., ...,  2.,  2.,  2.]])
&gt;&gt;&gt; np.sum(arr==2)
8532
&gt;&gt;&gt; np.sum(arr==3)
1468"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; import numpy as np
&gt;&gt;&gt; arr = np.ones((100, 100))
&gt;&gt;&gt; arr+=arr.T
&gt;&gt;&gt; arr
array([[ 2.,  2.,  2., ...,  2.,  2.,  2.],
       [ 2.,  2.,  2., ...,  2.,  2.,  2.],
       [ 2.,  2.,  2., ...,  2.,  2.,  2.],
       ..., 
       [ 3.,  3.,  3., ...,  2.,  2.,  2.],
       [ 3.,  3.,  3., ...,  2.,  2.,  2.],
       [ 3.,  3.,  3., ...,  2.,  2.,  2.]])
&gt;&gt;&gt; np.sum(arr==2)
8532
&gt;&gt;&gt; np.sum(arr==3)
1468
</code></pre></div>
<p dir="auto"><code class="notranslate">arr = arr + arr.T</code> works fine of course.</p>
<p dir="auto">It looks like because arr.T is a view of arr, while reading values out of arr.T it reads elements of arr that have already been written to.  This could lead to some really sneaky bugs. Even just detecting the situation and raising an exception would be an acceptable solution.</p>