How to sort in descending order with numpy? : <p>I have a numpy array like this:</p>

<pre><code>A = array([[1, 3, 2, 7],
           [2, 4, 1, 3],
           [6, 1, 2, 3]])
</code></pre>

<p>I would like to sort the rows of this matrix in descending order and get the arguments of the sorted matrix like this:</p>

<pre><code>As = array([[3, 1, 2, 0],
            [1, 3, 0, 2],
            [0, 3, 2, 1]])
</code></pre>

<p>I did the following:</p>

<pre><code>import numpy
A = numpy.array([[1, 3, 2, 7], [2, 4, 1, 3], [6, 1, 2, 3]])
As = numpy.argsort(A, axis=1)
</code></pre>

<p>But this gives me the sorting in ascending order. Also, after I spent some time looking for a solution in the internet, I expect that there must be an argument to <code>argsort</code> function from numpy that would reverse the order of sorting. But, apparently <strong>there is no such argument! Why!?</strong> </p>

<p>There is an argument called <code>order</code>. I tried, by guessing, <code>numpy.argsort(..., order=reverse)</code> but it does not work.</p>

<p>I looked for a solution in previous questions here and I found that I can do:</p>

<pre><code>import numpy
A = numpy.array([[1, 3, 2, 7], [2, 4, 1, 3], [6, 1, 2, 3]])
As = numpy.argsort(A, axis=1)
As = As[::-1]
</code></pre>

<p>For some reason, <code>As = As[::-1]</code> does not give me the desired output.</p>

<p>Well, I guess it must be simple but I am missing something.</p>

<p>How can I sort a numpy array in descending order?</p>
