如何在字典列表中进行3级排序?

时间:2017-05-20 05:56:31

标签: python python-2.7

这是我想在3级排序的json

例如:首先对remote_host进行排序,然后对client_ip进行排序,然后对时间戳进行排序,然后在单个json中进行输出。

data = [{"timestamp": 1495126917.0, "client_ip": "10.200.3.55", "remote_host": "175.106.59.78"},
        {"timestamp": 1495126915.0, "client_ip": "10.200.3.55", "remote_host": "175.106.59.78"},
        {"timestamp": 1495126917.0, "client_ip": "10.200.3.55", "remote_host": "201.83.41.11"},
        {"timestamp": 1495126913.0, "client_ip": "10.200.3.55", "remote_host": "78.47.139.58"},
        {"timestamp": 1495126915.0, "client_ip": "10.200.3.55", "remote_host": "175.106.59.78"},
        {"timestamp": 1495126917.0, "client_ip": "10.200.3.55", "remote_host": "201.83.41.11"},
        {"timestamp": 1495126913.0, "client_ip": "10.200.3.55", "remote_host": "201.83.41.11"},
        {"timestamp": 1495126915.0, "client_ip": "10.200.3.55", "remote_host": "78.47.139.58"},
        {"timestamp": 1495126913.0, "client_ip": "10.200.3.55", "remote_host": "175.106.59.78"},
        {"timestamp": 1495126915.0, "client_ip": "10.200.3.55", "remote_host": "201.83.41.11"}]

1 个答案:

答案 0 :(得分:2)

parent