hpcflow.sdk.core.utils.group_by_dict_key_values#

hpcflow.sdk.core.utils.group_by_dict_key_values(lst, *keys)#

Group a list of dicts according to specified equivalent key-values.

Parameters:
  • lst (list of dict) – The list of dicts to group together.

  • keys (tuple) – Dicts that have identical values for all of these keys will be grouped together into a sub-list.

Returns:

grouped

Return type:

list of list of dict

Examples

>>> group_by_dict_key_values([{'a': 1}, {'a': 2}, {'a': 1}], 'a')
[[{'a': 1}, {'a': 1}], [{'a': 2}]]