标签:ptime lse span lambda code false step 记录 for
dl = [ { "viewTimes": 236, "topTimes": 49, "stepsNum": 76, "collTimes": 321 }, { "viewTimes": 236, "topTimes": 47, "stepsNum": 58, "collTimes": 344 }, { "viewTimes": 238, "topTimes": 53, "stepsNum": 11, "collTimes": 321 }, { "viewTimes": 240, "topTimes": 31, "stepsNum": 39, "collTimes": 344 }, { "viewTimes": 240, "topTimes": 38, "stepsNum": 13, "collTimes": 200 }] # 按viewTimes升序排列,再按stepsNum升序排列 # dl2 = sorted(dl, key=lambda obj: (obj[‘viewTimes‘], obj[‘stepsNum‘]), reverse=False) # 按viewTimes升序排列,再按stepsNum降序排列 dl2 = sorted(dl, key=lambda obj: (obj[‘viewTimes‘], -obj[‘stepsNum‘]), reverse=False) dl_tmp[‘stepsNum‘], reverse=False) print(dl2) for temp in dl2: print(temp)
标签:ptime lse span lambda code false step 记录 for
原文地址:https://www.cnblogs.com/Vera-y/p/13292679.html