【Python小技巧】字典按key/value排序
2019-06-19 本文已影响0人
马尔克ov
按value排序
sorted(coupon_scores.items(), key=lambda x: x[1], reverse=True)
按key排序
sorted(coupon_scores.items(), key=lambda x: x[0], reverse=True)
sorted(coupon_scores.items(), key=lambda x: x[1], reverse=True)
sorted(coupon_scores.items(), key=lambda x: x[0], reverse=True)