---
title: "group by · RUAL Documentation"
description: "Groups the elements of the given array by a specified field."
canonical: https://docs.rual.nl/block-types/array/array_group_by
language: en
---

# group by

This block is part of the [`array`](https://docs.rual.nl/block-types/array) group and was last modified in core [`v10.4.28`](https://docs.rual.nl/core-versions/100428).

Groups the elements of the given array by a specified field.

- Array required `array` The array of objects to be grouped.

- field required `value` The field based on which to group the objects.

- Array `array` An array of objects representing groups, where each group has properties "group" (the grouping value) and "items" (an array of items in that group).

Groups items by the TEXT of the given field's value into objects of shape {group, items, count}, ordered by first appearance of each group value. Non-object items and items lacking the field fall into a group named "none". field defaults to "group" when unwired.

A typical wiring for [group by](https://docs.rual.nl/block-types/array/array_group_by): [map](https://docs.rual.nl/block-types/array/array_map) feeds the `array` pin; [value](https://docs.rual.nl/block-types/value/value_default) feeds the `field` pin; the `array` out pin feeds [sort array by field](https://docs.rual.nl/block-types/array/array_sort_condition).

![Studio canvas example for the group by block: typical wiring for group by.](https://docs.rual.nl/canvas-examples/array_group_by.png)

### Commonly used with

In production blueprints, this block is most often wired together with:

- [map](https://docs.rual.nl/block-types/array/array_map): feeds into this block. Creates a new array with the results of the provided function on every element in the array.

- [sort array by field](https://docs.rual.nl/block-types/array/array_sort_condition): this block feeds into it. Sorts the elements of an array by a given key.

- [value](https://docs.rual.nl/block-types/value/value_default): feeds into this block. Simply returns the provided value.

### Version history

Introduced in [`v10.4.28`](https://docs.rual.nl/core-versions/100428).
