python通过numpy进行排序
import numpy as np
list1 = [
[“57”, “小红”],
[“46”, “小乔”],
[“88”, “小张”],
[“38”, “小黑”],
[“6”, “小达”],
[“39”, “小分”],
[“95”, “小是”],
]
# print(np.sort(list2, axis=0))
a = [
[“小红”, “57”],
[“小乔”, “46”],
[“小张”, “88”],
[“小黑”, “38”],
[“小达”, “6”],
[“小分”, “39”],
[“小是”, “95”],
]
a = np.array(a)
# print(a[np.lexsort(a.T)])
print(a[a[:, 1].argsort()]) # 按第2列进行排序
a = [
[“1”, “数学”, 4],
[“2”, “语文”, 5],
[“3”, “计算机”, 9],
[“4”, “计算机”, 67]
]
print(a[0])
a = sorted(a, key=lambda x: (x[0]), reverse=True)
print(a)
def paixu(data_from_RPA, liehao):
data_from_RPA = sorted(data_from_RPA, key=lambda x: (x[liehao]), reverse=True)
for hang in data_from_RPA:
print(hang)
return data_from_RPA
print(paixu(a, 2))