I have a list of dicts as follows:
[{"server":"8.8.8.8",
"domains":[{"google.com":[{"time":15, "serial":14}, {"time":78, "serial":14}]},
{"intuit.com":[{"time":20, "serial":23}, {"time":91, "serial":18}]}
]
},
{"server":"8.8.4.4",
"domains":[{"google.com":[{"time":19, "serial":45}, {"time":92, "serial":76}]},
{"intuit.com":[{"time":45, "serial":89}, {"time":93, "serial":74}]}
]
},
{"server":"206.67.222.222",
"domains":[{"google.com":[{"time":98, "serial":76}, {"time":64, "serial":54}]},
{"intuit.com":[{"time":43, "serial":21}, {"time":65, "serial":59}]}
]
}]
How would I go about creating a structure where I select only the dict for each domain with the max serial number and when I have the same serial number, select the max time so that I am left with the following:
[{"server":"8.8.8.8",
"domains":[{"google.com":{"time":78, "serial":14}},
{"intuit.com":{"time":20, "serial":23}}
]
},
{"server":"8.8.4.4",
"domains":[{"google.com":{"time":92, "serial":76}},
{"intuit.com":{"time":45, "serial":89}}
]
},
{"server":"206.67.222.222",
"domains":[{"google.com":{"time":98, "serial":76}},
{"intuit.com":{"time":65, "serial":59}}
]
}]
See Question&Answers more detail:
os