here goes a first try: A[arange(2)[:,newaxis],indexes]
pau On 7/11/06, Emanuele Olivetti <[EMAIL PROTECTED]> wrote: > Hi, > I don't understand how to use argsort results. I have a 2D matrix and > I want to sort values in each row and obtain the index array of that > sorting. Argsort(1) is what I need, but the problem is how to use its > result in order to obtain a sorted matrix. Here is the simple example: > > A = array([[2,3,1],[5,4,6]]) > indexes = a.argsort(1) > > now indexes is: > array([[2, 0, 1], > [1, 0, 2]]) > > I'd like to apply indexes to A and obtain: > array([[1, 2, 3], > [4, 5, 6]]) > > or better, I'm interested both in a subset of indexes, i.e. indexes[:,1:], and > the related values of A matrix. > > How can I do this? If I simpy say: A[indexes] I get an IndexError. > > Thanks in advance, > > Emanuele > > P.S. numpy.__version__ is '0.9.8'. > > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Numpy-discussion mailing list > Numpy-discussion@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/numpy-discussion > ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion