<h3 dir="auto">Describe the issue:</h3>
<p dir="auto">wrong output.</p>
<h3 dir="auto">Reproduce the code example:</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np

mat = np.array([[7,5,1,6],[1,9,8,2],[2,7,3,8]])

mat
&gt;&gt;array([[7, 5, 1, 6],
         [1, 9, 8, 2],
         [2, 7, 3, 8]])

np.argsort(mat, axis=1)
&gt;&gt;array([[2, 1, 3, 0],
         [0, 3, 2, 1],
         [0, 2, 1, 3]])


# expected:
array([[3, 1, 0, 2],
       [0, 3, 2, 1],
       [0, 2, 1, 3]])"><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">mat</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([[<span class="pl-c1">7</span>,<span class="pl-c1">5</span>,<span class="pl-c1">1</span>,<span class="pl-c1">6</span>],[<span class="pl-c1">1</span>,<span class="pl-c1">9</span>,<span class="pl-c1">8</span>,<span class="pl-c1">2</span>],[<span class="pl-c1">2</span>,<span class="pl-c1">7</span>,<span class="pl-c1">3</span>,<span class="pl-c1">8</span>]])

<span class="pl-s1">mat</span><span class="pl-s1"></span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-en">array</span>([[<span class="pl-c1">7</span>, <span class="pl-c1">5</span>, <span class="pl-c1">1</span>, <span class="pl-c1">6</span>],
         [<span class="pl-c1">1</span>, <span class="pl-c1">9</span>, <span class="pl-c1">8</span>, <span class="pl-c1">2</span>],
         [<span class="pl-c1">2</span>, <span class="pl-c1">7</span>, <span class="pl-c1">3</span>, <span class="pl-c1">8</span>]])

<span class="pl-s1">np</span>.<span class="pl-en">argsort</span>(<span class="pl-s1">mat</span>, <span class="pl-s1">axis</span><span class="pl-c1">=</span><span class="pl-c1">1</span>)
<span class="pl-c1">&gt;&gt;</span><span class="pl-en">array</span>([[<span class="pl-c1">2</span>, <span class="pl-c1">1</span>, <span class="pl-c1">3</span>, <span class="pl-c1">0</span>],
         [<span class="pl-c1">0</span>, <span class="pl-c1">3</span>, <span class="pl-c1">2</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">3</span>]])


<span class="pl-c"># expected:</span>
<span class="pl-en">array</span>([[<span class="pl-c1">3</span>, <span class="pl-c1">1</span>, <span class="pl-c1">0</span>, <span class="pl-c1">2</span>],
       [<span class="pl-c1">0</span>, <span class="pl-c1">3</span>, <span class="pl-c1">2</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">3</span>]])</pre></div>
<h3 dir="auto">Error message:</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">NumPy/Python version information:</h3>
<p dir="auto">Name: numpy<br>
Version: 1.22.3<br>
Summary: NumPy is the fundamental package for array computing with Python.<br>
Home-page: <a href="https://www.numpy.org" rel="nofollow">https://www.numpy.org</a><br>
Author: Travis E. Oliphant et al.<br>
Author-email:<br>
License: BSD</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>