Python小技巧

93 阅读1分钟
  • 数组自定义排序
arr = [(0, 1, 1), (0, 2, 0)]
#sort according to third element of the tuple descendingly
arr = sorted(arr, key=lambda x:x[2], reverse=True)