scoreList?=?[
['a',98],
['c',45],
['b',70],
['d',85],
['h',85],
['f',92],
['g',30],
['e',65]
];
arrLen?=?len(scoreList);
for?i?in?range(arrLen):
a?=?scoreList[i]
for?j?in?range(arrLen):
b?=?scoreList[j-1]
if?b[1]<a[1]:
scoreList[i],scoreList[j-1]?=?scoreList[j-1],scoreList[i]
print(scoreList)
冒泡排序 也可以用自帶的排序函數 scoreList.sort(key=func) func是壹個自定義的函數 具體用法可以看文檔