import numpy as np# Let's use a as the variable name so we don't override the list keyworda = np.array([["A", 25, 2], ["B", 25, 3], ["C", 10, 1], ["D", 50, 25]])# Need to convert values to int, because they are being casted as string# in the original array (arrays only support one data type)key_values = a[:,1].astype(int) / a[:,2].astype(int)# Use argsort to get a sort index, then reverse the order to make it descendingindex_array = np.argsort(key_values)[::-1] # -1 reverses the orderprint(a[index_array])输出:[['A' '25' '2'] ['C' '10' '1'] ['B' '25' '3'] ['D' '50' '25']]