maxiddict[rowdict['id']] = [rowdict['seq'], rowdict['sum'], first_foo,
    rowdict['foo']]
groupdict = {}
for k, v in list(maxiddict.items()):
    key = ', '.join([str(v[2]), str(v[3])])
if not groupdict.get(key):
    groupdict[key] = [dict([(k, v)])]
else:
    groupdict[key].append(dict([(k, v)]))
lowestsumsdict = {}
for groupkey, groupvallist in list(groupdict.items()):
    minsum = min([iter(entry.values()).next()[1] for entry in groupvallist])
lowestsumsdict[groupkey] = minsum
print(lowestsumsdict)
Get max values by category in list of dictionaries