You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2019/01/11 06:52:00 UTC

[GitHub] huangzhiyuan commented on issue #13844: Sort operation does not support return index

huangzhiyuan commented on issue #13844: Sort operation does not support return index
URL: https://github.com/apache/incubator-mxnet/issues/13844#issuecomment-453397904
 
 
   Maybe you can try [argsort()](https://mxnet.incubator.apache.org/api/python/ndarray/ndarray.html?highlight=sort#mxnet.ndarray.argsort):
   ```
   >>> x = nd.normal(shape=(3,4))
   >>> x
   [[-0.03716067 -0.48774993 -0.02261727  0.57461417]
    [ 1.4661262   0.6862904   0.35496104  1.0731696 ]
    [ 0.12017461 -0.9711102  -0.77569664 -0.7882176 ]]
   <NDArray 3x4 @cpu(0)>
   >>> x.sort()
   [[-0.48774993 -0.03716067 -0.02261727  0.57461417]
    [ 0.35496104  0.6862904   1.0731696   1.4661262 ]
    [-0.9711102  -0.7882176  -0.77569664  0.12017461]]
   <NDArray 3x4 @cpu(0)>
   >>> x.argsort()
   [[1. 0. 2. 3.]
    [2. 1. 3. 0.]
    [1. 3. 2. 0.]]
   
   <NDArray 3x4 @cpu(0)>
   >>> x.sort(0)
   [[-0.03716067 -0.9711102  -0.77569664 -0.7882176 ]
    [ 0.12017461 -0.48774993 -0.02261727  0.57461417]
    [ 1.4661262   0.6862904   0.35496104  1.0731696 ]]
   <NDArray 3x4 @cpu(0)>
   >>> x.argsort(0)
   [[0. 2. 2. 2.]
    [2. 0. 0. 0.]
    [1. 1. 1. 1.]]
   <NDArray 3x4 @cpu(0)>
   ```
   Hope it's useful for you :)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services