python numpy 联合间接排序与插入排序
"""
联合间接排序
插入排序
"""
import numpy as np
prices = np.array([92, 83, 71, 92, 40, 12, 71])
volumes = np.array([100, 251, 4, 12, 709, 34, 75])
print(volumes)
names = ['Product1', 'Product2', 'Product3', 'Product4', 'Product5', 'Product6', 'Product7']
ind = np.lexsort((volumes * -1, prices))
print(ind)
for i in ind:
print(names[i], end=' ')
print("")
print("*" * 45)
a = np.array([1, 2, 4, 5, 6, 8, 9])
b = np.array([7, 3])
c = np.searchsorted(a, b)
print(c)
d = np.insert(a, c, b)
print(d)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/c5146782de4a1c1ac3f49ba3189dd65e.png)