# group\_by\_exp

Groups an array elements based on item property value meeting given condition

```
{% json employees %}
  [
    {
      "first_name": "Ann",
      "last_name": "Smith",
      "position": "Accountant",
      "city": "New York",
      "age": 25
    },
    {
      "first_name": "Adam",
      "last_name": "Fox",
      "position": "Salesman",
      "city": "New Jersey",
      "age": 35
    },
    {
      "first_name": "Angela",
      "last_name": "Newman",
      "position": "Accountant",
      "city": "Boston",
      "age": 43
    }
  ]
{% endjson %}
{% assign group_by_exp_age_result = employees | group_by_exp: "item", "item.age >= 30" %}
{{ group_by_exp_age_result | log }}
```

Results in following array logged to console:

```
[
  {
    "name": false,
    "items": [
      {
        "first_name": "Ann",
        "last_name": "Smith",
        "position": "Accountant",
        "city": "New York",
        "age": 25
      }
    ]
  },
  {
    "name": true,
    "items": [
      {
        "first_name": "Adam",
        "last_name": "Fox",
        "position": "Salesman",
        "city": "New Jersey",
        "age": 35
      },
      {
        "first_name": "Angela",
        "last_name": "Newman",
        "position": "Accountant",
        "city": "Boston",
        "age": 43
      }
    ]
  }
]
```
