python实现两个数组同时排序

阅读 141

2022-05-05

用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)

0 0 举报