# Collection Filters
Collection filters work with arrays and objects.
## first
Returns the first element of an array.
```html
```
## last
Returns the last element of an array.
```html
```
## length
Returns the number of elements.
```html
```
## reverse
Reverses an array or string.
```html
```
## sort
Sorts an array.
```html
```
## group_by
Groups array elements by a field.
```html
{% for role, users in users_list | group_by(attribute="role") %}
{{ role }}: {% for u in users %}{{ u.name }}{% endfor %}
{% endfor %}
```
## where
Filters array elements by a condition.
```html
```
## pluck
Extracts a field from all objects in an array.
```html
```
## join
Joins array elements with a separator.
```html
```
## slice
Returns a portion of an array or string.
```html
```
## uniq
Returns unique elements.
```html
```
## shuffle
Randomly shuffles array elements.
```html
```