0
点赞
收藏
分享

微信扫一扫

python实现两个数组同时排序

半夜放水 2022-05-05 阅读 139

用numpy.argsort函数

import numpy as np
a=[1,2,3,6,5,4]
b=["one","two","three","six","five","four"]
b=np.array(b)
sorted_indices=np.argsort(a)
print(sorted_indices)
sorted_b=b[sorted_indices]
print(sorted_b)

运行结果:
在这里插入图片描述

参考链接:
1.https://blog.csdn.net/junlee87/article/details/78636053

举报

相关推荐

0 条评论