{% set items = [
  { account_id: 'account-x10', product: 'Chair' },
  { account_id: 'account-x10', product: 'Bookcase' },
  { account_id: 'account-x11', product: 'Desk' },
] | group_by('account_id') %}

{# output:
{
  'account-x10': [
      { account_id: 'account-x10', product: 'Chair' },
      { account_id: 'account-x10', product: 'Bookcase' },
  ],
  'account-x11': [
      { account_id: 'account-x11', product: 'Desk' },
  ]
}
#}

Arguments

ArgumentDescriptionType
keyThe key to group by.String

Was this helpful?

Copyright © 2024 Blutui.