我有一个从nagios的MySQL查询中提取的列表列表。我试图按第3列中的降序排序SORT,而第2列也是GROUP。
[['', 'All Events', 73], ['', 'check_asterisk_calls2-TEL', 1], ['pteln002', 'check_asterisk_calls2-TEL', 1], ['', 'check_asterisk_extension_error-TEL', 1], ['pteln004', 'check_asterisk_extension_error-TEL', 1], ['', 'check_es_snaps-UNX', 1], ['psearchpr005', 'check_es_snaps-UNX', 1], ['', 'check_exchange_mailqueue-WIN', 1], ['pexc001', 'check_exchange_mailqueue-WIN', 1], ['', 'check_health_measure-JVA', 2], ['pwspr031', 'check_health_measure-JVA', 1], ['pwspr049', 'check_health_measure-JVA', 1], ['', 'check_http_prod-JVA', 3], ['putpr002', 'check_http_prod-JVA', 1], ['putpr004', 'check_http_prod-JVA', 1], ['pwspr031', 'check_http_prod-JVA', 1], ['', 'check_jmx_HeapMemoryUsage_background-JVA', 1], ['putpr001', 'check_jmx_HeapMemoryUsage_background-JVA', 1], ['', 'check_localtouch-TEL', 1], ['pteln002', 'check_localtouch-TEL', 1], ['', 'check_nfs_health-UNX', 12], ['psearchpr005', 'check_nfs_health-UNX', 1], ['psearchpr006', 'check_nfs_health-UNX', 1], ['psearchpr007', 'check_nfs_health-UNX', 1], ['psearchpr008', 'check_nfs_health-UNX', 1], ['pteln001', 'check_nfs_health-UNX', 1], ['pteln002', 'check_nfs_health-UNX', 1], ['pteln003', 'check_nfs_health-UNX', 1], ['pteln004', 'check_nfs_health-UNX', 1], ['pteln005', 'check_nfs_health-UNX', 1], ['pteln007', 'check_nfs_health-UNX', 1], ['pteln009', 'check_nfs_health-UNX', 1], ['pteln010', 'check_nfs_health-UNX', 1], ['', 'check_tomcat-sem-UNX', 1], ['rwspr001', 'check_tomcat-sem-UNX', 1], ['', 'check_tomcat-UNX', 1], ['putpr002', 'check_tomcat-UNX', 1], ['', 'check_total_procs-UNX', 1], ['naggy2', 'check_total_procs-UNX', 1], ['', 'check_w305_KC_standby-DBA', 1], ['pdbdrkc01', 'check_w305_KC_standby-DBA', 1], ['', 'CPU-Load-UNX', 9], ['pfspr02', 'CPU-Load-UNX', 1], ['pmsvpr001', 'CPU-Load-UNX', 1], ['psearchpr005', 'CPU-Load-UNX', 1], ['psearchpr006', 'CPU-Load-UNX', 1], ['psearchpr007', 'CPU-Load-UNX', 1], ['putpr001', 'CPU-Load-UNX', 1], ['putpr004', 'CPU-Load-UNX', 1], ['pwspr031', 'CPU-Load-UNX', 1], ['pwspr049', 'CPU-Load-UNX', 1], ['', 'disk-usage-UNX', 1], ['pmsvpr007', 'disk-usage-UNX', 1], ['', 'memory-usage-UNX', 25], ['p0crmpr001', 'memory-usage-UNX', 1], ['p0crmpr002', 'memory-usage-UNX', 1], ['pmsvpr002', 'memory-usage-UNX', 1], ['pmsvpr008', 'memory-usage-UNX', 1], ['pwspr013', 'memory-usage-UNX', 1], ['pwspr014', 'memory-usage-UNX', 1], ['pwspr019', 'memory-usage-UNX', 1], ['pwspr022', 'memory-usage-UNX', 1], ['pwspr024', 'memory-usage-UNX', 1], ['pwspr025', 'memory-usage-UNX', 1], ['pwspr026', 'memory-usage-UNX', 1], ['pwspr027', 'memory-usage-UNX', 1], ['pwspr030', 'memory-usage-UNX', 1], ['pwspr031', 'memory-usage-UNX', 1], ['pwspr032', 'memory-usage-UNX', 1], ['pwspr033', 'memory-usage-UNX', 1], ['pwspr036', 'memory-usage-UNX', 1], ['pwspr041', 'memory-usage-UNX', 1], ['pwspr042', 'memory-usage-UNX', 1], ['pwspr043', 'memory-usage-UNX', 1], ['pwspr044', 'memory-usage-UNX', 1], ['pwspr045', 'memory-usage-UNX', 1], ['pwspr046', 'memory-usage-UNX', 1], ['pwspr049', 'memory-usage-UNX', 1], ['pwspr050', 'memory-usage-UNX', 1], ['', 'new_pending_phone-TEL', 1], ['pdbpr01', 'new_pending_phone-TEL', 1], ['', 'prod-consumer-rating-rewards-JVA', 1], ['Prod-MicroServices', 'prod-consumer-rating-rewards-JVA', 1], ['', 'prod-credit-request-JVA', 1], ['Prod-MicroServices', 'prod-credit-request-JVA', 1], ['', 'prod-ha-spd-update-JVA', 1], ['Prod-MicroServices', 'prod-ha-spd-update-JVA', 1], ['', 'prod-payment-batch-JVA', 1], ['Prod-MicroServices', 'prod-payment-batch-JVA', 1], ['', 'prod-session-log-loader-JVA', 1], ['Prod-MicroServices', 'prod-session-log-loader-JVA', 1], ['', 'prod-sm-caldav-event-JVA', 1], ['Prod-MicroServices', 'prod-sm-caldav-event-JVA', 1], ['', 'prod-sp-task-coverage-indexer-JVA', 1], ['Prod-MicroServices', 'prod-sp-task-coverage-indexer-JVA', 1], ['', 'prod-watcher-JVA', 1], ['Prod-MicroServices', 'prod-watcher-JVA', 1], ['', 'prod-ws-communication-JVA', 1], ['Prod-MicroServices', 'prod-ws-communication-JVA', 1], ['', 'prod-ws-entity-JVA', 1], ['Prod-MicroServices', 'prod-ws-entity-JVA', 1]]
以下是我想要输出的示例:
[['', 'All Events', 73], ['', 'memory-usage-UNX', 25], ['p0crmpr001', 'memory-usage-UNX', 1], ['p0crmpr002', 'memory-usage-UNX', 1], ['pmsvpr002', 'memory-usage-UNX', 1], ['pmsvpr008', 'memory-usage-UNX', 1], ['pwspr013', 'memory-usage-UNX', 1], ['pwspr014', 'memory-usage-UNX', 1], ['pwspr019', 'memory-usage-UNX', 1], ['pwspr022', 'memory-usage-UNX', 1], ['pwspr024', 'memory-usage-UNX', 1], ['pwspr025', 'memory-usage-UNX', 1], ['pwspr026', 'memory-usage-UNX', 1], ['pwspr027', 'memory-usage-UNX', 1], ['pwspr030', 'memory-usage-UNX', 1], ['pwspr031', 'memory-usage-UNX', 1], ['pwspr032', 'memory-usage-UNX', 1], ['pwspr033', 'memory-usage-UNX', 1], ['pwspr036', 'memory-usage-UNX', 1], ['pwspr041', 'memory-usage-UNX', 1], ['pwspr042', 'memory-usage-UNX', 1], ['pwspr043', 'memory-usage-UNX', 1], ['pwspr044', 'memory-usage-UNX', 1], ['pwspr045', 'memory-usage-UNX', 1], ['pwspr046', 'memory-usage-UNX', 1], ['pwspr049', 'memory-usage-UNX', 1], ['pwspr050', 'memory-usage-UNX', 1], ['', 'check_nfs_health-UNX', 12], ['psearchpr005', 'check_nfs_health-UNX', 1], ['psearchpr006', 'check_nfs_health-UNX', 1], ['psearchpr007', 'check_nfs_health-UNX', 1], ['psearchpr008', 'check_nfs_health-UNX', 1], ['pteln001', 'check_nfs_health-UNX', 1], ['pteln002', 'check_nfs_health-UNX', 1], ['pteln003', 'check_nfs_health-UNX', 1], ['pteln004', 'check_nfs_health-UNX', 1], ['pteln005', 'check_nfs_health-UNX', 1], ['pteln007', 'check_nfs_health-UNX', 1], ['pteln009', 'check_nfs_health-UNX', 1], ['pteln010', 'check_nfs_health-UNX', 1], ['', 'CPU-Load-UNX', 9], ['pfspr02', 'CPU-Load-UNX', 1], ['pmsvpr001', 'CPU-Load-UNX', 1], ['psearchpr005', 'CPU-Load-UNX', 1], ['psearchpr006', 'CPU-Load-UNX', 1], ['psearchpr007', 'CPU-Load-UNX', 1], ['putpr001', 'CPU-Load-UNX', 1], ['putpr004', 'CPU-Load-UNX', 1], ['pwspr031', 'CPU-Load-UNX', 1], ['pwspr049', 'CPU-Load-UNX', 1], ['', 'check_http_prod-JVA', 3], ['putpr002', 'check_http_prod-JVA', 1], ['putpr004', 'check_http_prod-JVA', 1], ['pwspr031', 'check_http_prod-JVA', 1], ['', 'check_health_measure-JVA', 2], ['pwspr031', 'check_health_measure-JVA', 1], ['pwspr049', 'check_health_measure-JVA', 1], ['', 'prod-ws-entity-JVA', 1], ['Prod-MicroServices', 'prod-ws-entity-JVA', 1], ['', 'prod-ws-communication-JVA', 1], ['Prod-MicroServices', 'prod-ws-communication-JVA', 1], ['', 'prod-watcher-JVA', 1], ['Prod-MicroServices', 'prod-watcher-JVA', 1], ['', 'prod-sp-task-coverage-indexer-JVA', 1], ['Prod-MicroServices', 'prod-sp-task-coverage-indexer-JVA', 1], ['', 'prod-sm-caldav-event-JVA', 1], ['Prod-MicroServices', 'prod-sm-caldav-event-JVA', 1], ['', 'prod-session-log-loader-JVA', 1], ['Prod-MicroServices', 'prod-session-log-loader-JVA', 1], ['', 'prod-payment-batch-JVA', 1], ['Prod-MicroServices', 'prod-payment-batch-JVA', 1], ['', 'prod-ha-spd-update-JVA', 1], ['Prod-MicroServices', 'prod-ha-spd-update-JVA', 1], ['', 'prod-credit-request-JVA', 1], ['Prod-MicroServices', 'prod-credit-request-JVA', 1], ['', 'prod-consumer-rating-rewards-JVA', 1], ['Prod-MicroServices', 'prod-consumer-rating-rewards-JVA', 1], ['', 'new_pending_phone-TEL', 1], ['pdbpr01', 'new_pending_phone-TEL', 1]]
这个例子中有一些缺失,因为我必须手工完成,但这个想法就在那里。
我以为我得到了以下答案,但它甚至没有关闭。
weeklyreport = sorted(weeklyreport, key = lambda x: (x[2], x[1]), reverse=True)
任何帮助都将不胜感激。