container[key].update(values)
new_dataset = [dict([(group_by_key, item[0])] + list(item[1].items())) for item in
    list(container.items())]
new_dataset.sort(key=lambda item: item[group_by_key])
return new_dataset
Group by and aggregate the values of a list of dictionaries in Python