python 排序列表按列表中元祖資料排序
阿新 • • 發佈:2018-12-31
1 lists = [(2, 2, '水象科技,騙子', 3), (2, 2, '水象科技,傳銷', 3), (2, 2, '水象科技,被調查', 3), (2, 2, '水象科技,被查', 3), (2, 2, '水象科技,被騙', 3), (2, 2, '水象科技,騙局', 3), (2, 2, '水象科技,虛假', 3), (2, 2, '水象科技,謊言', 3), (2, 2, '水象科技,裁員', 3), (2, 2, '水象科技,倒閉', 3), (2, 2, '水象科技,跑路', 3), (2, 2, '水象科技,造假', 3), (2, 2, '水象科技,害人', 3), (2, 2, '水象科技,假冒', 3), (2, 2, '水象科技,涉嫌', 3), (2, 2, '水象科技,潛逃', 3), (2, 2, '水象科技,獲刑', 3), (2, 2, '水象科技,批捕', 3), (2, 2, '水象科技,抓捕', 3), (2, 2, '水象科技,逮捕', 3), (2, 2, '水象科技,淪落', 3), (2, 2, '水象科技,破產', 3), (2, 2, '水象科技,坑人', 3), (2, 2, '水象科技,騙人', 3), (2, 2, '水象科技,詐騙', 3), (2, 2, '水象科技,蒙人', 3), (2, 2, '水象科技,虛假宣傳', 3), (2, 2, '水象科技,貓膩', 3), (4, 1, '香港必發集團網站', 3), (4, 1, 'DZ81', 3), (4, 1, 'SLD', 3), (4, 1, 'EX/CL', 3), (4, 1, 'ET-', 3), (4, 1, 'LNRM', 3), (4, 1, 'EX/', 3), (4, 1, 'SZ1', 3), (4, 1, 'GLXX', 3), (4, 1, 'DSM', 3), (4, 1, '金沙遊樂場提款', 3), (4, 1, 'ASE', 3), (4, 1, 'XM-', 3), (4, 1, 'BQM', 3), (4, 1, 'RL/', 3), (4, 1, 'HLC', 3), (4, 1, 'PT/S', 3), (4, 1, 'DLE', 3), (4, 1, 'MDH', 3), (4, 1, 'K-BU', 3), (4, 1, 'EPX', 3), (4, 1, 'UP525', 3), (4, 1, 'ECS', 3), (4, 1, 'UP511', 3), (4, 1, 'DR6', 3), (4, 1, 'DR0', 3), (4, 1, 'N512', 3), (4, 1, 'TYA', 3), (4, 1, 'GE5', 3), (4, 1, 'N510', 3), (4, 1, 'DH100', 3), (4, 2, '海普瑞,富陽到文登汽車時刻表', 3), (4, 1, '老虎官網', 3), (4, 1, '中華康網', 3), (4, 1, '賭足球', 3), (4, 1, '棋牌', 3), (4, 1, '江蘇省電子商務企業信用資訊公示服務網', 3), (4, 1, '捕魚', 3), (4, 1, '威尼斯', 3), (4, 1, 'NHR', 3), (4, 1, 'YWD-I', 3), (4, 1, '新疆隊與企業員工打友誼賽', 3), (4, 1, '058期', 3), (4, 1, '不鏽鋼專案', 3), (4, 1, 'GD8', 3), (4, 1, 'YWB-AC1', 3), (4, 1, 'MIK', 3), (4, 1, '遵義回收鉭塊', 3), (4, 1, '崇左', 3), (4, 1, '互助系統開發', 3), (4, 1, '漁樂帝國', 3), (4, 1, '亞盤', 3), (4, 1, 'BD-4P-', 3), (4, 1, '微信龍虎群', 3), (4, 1, '道聚城', 3), (4, 1, 'JD194-BS4Q-', 3), (4, 1, '試玩金', 3), (4, 1, '數顯儀', 3), (4, 1, '測控儀', 3), (4, 1, 'DP3', 3), (4, 1, '中國科學院', 3), (4, 1, '三相電', 3), (4, 1, '電壓表', 3), (4, 1, '數顯表', 3), (4, 1, '電力儀表', 3), (4, 1, '功能儀表', 3), (4, 1, '電流表', 3), (4, 1, '電能表', 3), (4, 1, '賭博網', 3), (4, 2, '望京,一場大秀', 3), (4, 1, '迷魂藥', 3), (4, 1, '海神樂', 3), (4, 1, '南京開發票', 3), (4, 1, '說真話的藥', 3), (4, 1, '電玩城加盟', 3), (4, 1, '公安部官方', 3), (4, 1, '培訓機構', 3), (4, 1, '昏迷', 3), (4, 1, '龍江到十堰市', 3), (4, 1, '南湖公園', 3), (4, 1, '度芽智慧體溫貼', 3), (4, 1, '新建小區', 3), (4, 1, '迷情水', 3), (4, 1, '睡蓮', 3), (4, 1, '管理合夥人', 3), (4, 1, '中國科學院', 3), (4, 1, '幸運飛艇', 3), (1, 2, '水象科技,合作', 1), (1, 2, '水象科技,攜手', 1), (1, 2, '水象科技,愛心公益', 1)] 2 st_data = sorted(lists, key=lambda x: x[3], reverse=False) 3 print(st_data) #[(1, 2, '水象科技,合作', 1), (1, 2, '水象科技,攜手', 1), (1, 2, '水象科技,愛心公益', 1), (2, 2, '水象科技,騙子', 3), (2, 2, '水象科技,傳銷', 3), (2, 2, '水象科技,被調查', 3), (2, 2, '水象科技,被查', 3), (2, 2, '水象科技,被騙', 3), (2, 2, '水象科技,騙局', 3), (2, 2, '水象科技,虛假', 3), (2, 2, '水象科技,謊言', 3), (2, 2, '水象科技,裁員', 3), (2, 2, '水象科技,倒閉', 3), (2, 2, '水象科技,跑路', 3), (2, 2, '水象科技,造假', 3), (2, 2, '水象科技,害人', 3), (2, 2, '水象科技,假冒', 3), (2, 2, '水象科技,涉嫌', 3), (2, 2, '水象科技,潛逃', 3), (2, 2, '水象科技,獲刑', 3), (2, 2, '水象科技,批捕', 3), (2, 2, '水象科技,抓捕', 3), (2, 2, '水象科技,逮捕', 3), (2, 2, '水象科技,淪落', 3), (2, 2, '水象科技,破產', 3), (2, 2, '水象科技,坑人', 3), (2, 2, '水象科技,騙人', 3), (2, 2, '水象科技,詐騙', 3), (2, 2, '水象科技,蒙人', 3), (2, 2, '水象科技,虛假宣傳', 3), (2, 2, '水象科技,貓膩', 3), (4, 1, '香港必發集團網站', 3), (4, 1, 'DZ81', 3), (4, 1, 'SLD', 3), (4, 1, 'EX/CL', 3), (4, 1, 'ET-', 3), (4, 1, 'LNRM', 3), (4, 1, 'EX/', 3), (4, 1, 'SZ1', 3), (4, 1, 'GLXX', 3), (4, 1, 'DSM', 3), (4, 1, '金沙遊樂場提款', 3), (4, 1, 'ASE', 3), (4, 1, 'XM-', 3), (4, 1, 'BQM', 3), (4, 1, 'RL/', 3), (4, 1, 'HLC', 3), (4, 1, 'PT/S', 3), (4, 1, 'DLE', 3), (4, 1, 'MDH', 3), (4, 1, 'K-BU', 3), (4, 1, 'EPX', 3), (4, 1, 'UP525', 3), (4, 1, 'ECS', 3), (4, 1, 'UP511', 3), (4, 1, 'DR6', 3), (4, 1, 'DR0', 3), (4, 1, 'N512', 3), (4, 1, 'TYA', 3), (4, 1, 'GE5', 3), (4, 1, 'N510', 3), (4, 1, 'DH100', 3), (4, 2, '海普瑞,富陽到文登汽車時刻表', 3), (4, 1, '老虎官網', 3), (4, 1, '中華康網', 3), (4, 1, '賭足球', 3), (4, 1, '棋牌', 3), (4, 1, '江蘇省電子商務企業信用資訊公示服務網', 3), (4, 1, '捕魚', 3), (4, 1, '威尼斯', 3), (4, 1, 'NHR', 3), (4, 1, 'YWD-I', 3), (4, 1, '新疆隊與企業員工打友誼賽', 3), (4, 1, '058期', 3), (4, 1, '不鏽鋼專案', 3), (4, 1, 'GD8', 3), (4, 1, 'YWB-AC1', 3), (4, 1, 'MIK', 3), (4, 1, '遵義回收鉭塊', 3), (4, 1, '崇左', 3), (4, 1, '互助系統開發', 3), (4, 1, '漁樂帝國', 3), (4, 1, '亞盤', 3), (4, 1, 'BD-4P-', 3), (4, 1, '微信龍虎群', 3), (4, 1, '道聚城', 3), (4, 1, 'JD194-BS4Q-', 3), (4, 1, '試玩金', 3), (4, 1, '數顯儀', 3), (4, 1, '測控儀', 3), (4, 1, 'DP3', 3), (4, 1, '中國科學院', 3), (4, 1, '三相電', 3), (4, 1, '電壓表', 3), (4, 1, '數顯表', 3), (4, 1, '電力儀表', 3), (4, 1, '功能儀表', 3), (4, 1, '電流表', 3), (4, 1, '電能表', 3), (4, 1, '賭博網', 3), (4, 2, '望京,一場大秀', 3), (4, 1, '迷魂藥', 3), (4, 1, '海神樂', 3), (4, 1, '南京開發票', 3), (4, 1, '說真話的藥', 3), (4, 1, '電玩城加盟', 3), (4, 1, '公安部官方', 3), (4, 1, '培訓機構', 3), (4, 1, '昏迷', 3), (4, 1, '龍江到十堰市', 3), (4, 1, '南湖公園', 3), (4, 1, '度芽智慧體溫貼', 3), (4, 1, '新建小區', 3), (4, 1, '迷情水', 3), (4, 1, '睡蓮', 3), (4, 1, '管理合夥人', 3), (4, 1, '中國科學院', 3), (4, 1, '幸運飛艇', 3)]