<p dir="auto">np.argsort([7,4,5])</p>
<blockquote>
<p dir="auto">array([1, 2, 0])</p>
</blockquote>
<p dir="auto">Expected behaviour should be array([2,0,1])</p>
<p dir="auto">The argsort function seems to be broken. Looking at the code provided, the argsort for rows [0, 1] is correct but it's messed up for rows [2, 3].<br>
I tested this on different NumPy installations and versions 1.11.0 and 1.12.0</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np

vec = np.array([
    [-1.4, -1.2,  1.3],
    [-3.6,  3.9, -3.7],
    [-2.3,  1.5, -2. ],
    [-2.6,  2.4, -1.6]
    ])

In [1]: np.argsort(-vec, axis=1)
Out[1]: 
array([[2, 1, 0],
       [1, 0, 2],
       [1, 2, 0],
       [1, 2, 0]])"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>

<span class="pl-s1">vec</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([
    [<span class="pl-c1">-</span><span class="pl-c1">1.4</span>, <span class="pl-c1">-</span><span class="pl-c1">1.2</span>,  <span class="pl-c1">1.3</span>],
    [<span class="pl-c1">-</span><span class="pl-c1">3.6</span>,  <span class="pl-c1">3.9</span>, <span class="pl-c1">-</span><span class="pl-c1">3.7</span>],
    [<span class="pl-c1">-</span><span class="pl-c1">2.3</span>,  <span class="pl-c1">1.5</span>, <span class="pl-c1">-</span><span class="pl-c1">2.</span> ],
    [<span class="pl-c1">-</span><span class="pl-c1">2.6</span>,  <span class="pl-c1">2.4</span>, <span class="pl-c1">-</span><span class="pl-c1">1.6</span>]
    ])

<span class="pl-v">In</span> [<span class="pl-c1">1</span>]: <span class="pl-s1">np</span>.<span class="pl-en">argsort</span>(<span class="pl-c1">-</span><span class="pl-s1">vec</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">1</span>)
<span class="pl-v">Out</span>[<span class="pl-c1">1</span>]: 
<span class="pl-en">array</span>([[<span class="pl-c1">2</span>, <span class="pl-c1">1</span>, <span class="pl-c1">0</span>],
       [<span class="pl-c1">1</span>, <span class="pl-c1">0</span>, <span class="pl-c1">2</span>],
       [<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">0</span>],
       [<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">0</span>]])</pre></div>