Jay*_*Jay 2 python matlab python-2.7
我对Python语言很陌生,想知道以下内容
(1) y = [some vector]
(2) z = [some other vector]
(3) [ynew,indx] = sort(y)
(4) znew = z(indx)
Run Code Online (Sandbox Code Playgroud)
我可以做1,2和4行,但是3行适合我。有什么建议么。我要寻找的不是用户编写的功能,而是语言本身固有的功能。
谢谢
对于第3行使用NumPy,假设y是行向量,否则axis=0需要:
ynew=y.sort(axis=1)
indx=y.argsort(axis=1)
Run Code Online (Sandbox Code Playgroud)