# Array

Array filters modify [arrays](/docs/theme/references/liquid/basics/liquid-types#array).

## concat

`array | concat: array`

Concatenates (combines) two arrays.

**note**

The `concat` filter won't filter out duplicates. If you want to remove duplicates, then you need to use the [uniq filter](/docs/theme/references/liquid/filters/array-filters#uniq).

**Code**

```liquid
{% assign cold_climate_fruits = 'Apple,Pear' | split: ',' %}
{% assign warm_climate_fruits = 'Dragon fruit,Mango' | split: ',' %}
{% assign all_fruits = cold_climate_fruits | concat: warm_climate_fruits %}

{% for fruit in all_fruits %}
  {{ fruit }}
{% endfor %}
```

**Output**

```html
Apple
Pear
Dragon fruit
Mango
```

## first

`array | first`

Returns the first item in an array.

**Code**

```liquid
{% assign first_product = collection.products | first %}

{{ first_product.title }}
```

**Data**

```json
{
  "collection": {
    "products": [
      {
        "title": "Fit 3 Denim Shirt"
      },
      {
        "title": "Ace Cashmere Beanie"
      }
    ]
  }
}
```

**Output**

```html
Fit 3 Denim Shirt
```

## join

`array | join`

returns  [string](../basics/liquid-types#string)

Combines all of the items in an array into a single [string](/docs/theme/references/liquid/basics/liquid-types#string), separated by a space.

**Code**

```liquid
{{ collection.tags | join }}
```

**Data**

```json
{
  "collection": {
    "tags": [
      "cold",
      "fresh",
      "large"
    ]
  }
}
```

**Output**

```html
cold fresh large
```

### Custom separator

`array | join: string`

You can specify a custom separator for the joined items.

**Code**

```liquid
{{ collection.tags | join: ', ' }}
```

**Data**

```json
{
  "collection": {
    "tags": [
      "cold",
      "fresh",
      "large"
    ]
  }
}
```

**Output**

```html
cold, fresh, large
```

## last

`array | last`

Returns the last item in an array.

**Code**

```liquid
{% assign last_product = collection.products | last %}

{{ last_product.title }}
```

**Data**

```json
{
  "collection": {
    "products": [
      {
        "title": "Fit 3 Denim Shirt"
      },
      {
        "title": "Ace Cashmere Beanie"
      }
    ]
  }
}
```

**Output**

```html
Ace Cashmere Beanie
```

## map

`array | map: string`

Creates an array of values from a specific property of the items in an array.

**Code**

```liquid
{% assign product_titles = collection.products | map: 'title' %}

{{ product_titles | join: '@' }}
```

**Data**

```json
{
  "collection": {
    "products": [
      {
        "title": "Fit 3 Denim Shirt"
      },
      {
        "title": "Ace Cashmere Beanie"
      }
    ]
  }
}
```

**Output**

```html
Fit 3 Denim Shirt@Ace Cashmere Beanie
```

## reverse

`array | reverse`

Reverses the order of the items in an array.

**Code**

```liquid
Original order:
{{ collection.products | map: 'title' | join: '@' }}

Reverse order:
{{ collection.products | reverse | map: 'title' | join: '@' }}
```

**Data**

```json
{
  "collection": {
    "products": [
      {
        "title": "Fit 3 Denim Shirt"
      },
      {
        "title": "Ace Cashmere Beanie"
      }
    ]
  }
}
```

**Output**

```html
Original order:
Fit 3 Denim Shirt@Ace Cashmere Beanie

Reverse order:
Ace Cashmere Beanie@Fit 3 Denim Shirt
```

## size

`variable | size`

returns  [number](../basics/liquid-types#number)

Returns the size of a string or array.

The size of a string is the number of characters that the string includes. The size of an array is the number of items in the array.

**Code**

```liquid
{{ collection.title | size }}
{{ collection.products | size }}
```

**Output**

```html
17
2
```

## sort

`array | sort`

Sorts the items in an array in case-sensitive alphabetical, or numerical, order.

**Code**

```liquid
{% assign tags = collection.tags | sort %}

{% for tag in tags %}
   {{ tag }}
{% endfor %}
```

**Data**

```json
{
  "collection": {
    "tags": [
      "Burning",
      "fresh",
      "music",
      "plant",
      "Salty"
    ]
  }
}

```

**Output**

```html
Burning
Salty
fresh
music
plant
```

### Sort by an array item property

`array | sort: string`

You can specify an array item property to sort the array items by. You can sort by any property of the object that you're sorting.

**Code**

```liquid
{% assign products = collection.products | sort: 'price' %}

{% for product in products %}
  {{ product.title }}
{% endfor %}
```

**Data**

```json
{
  "collection": {
    "products": [
      {
        "title": "Fit 3 Denim Shirt",
        "price": "22.00"
      },
      {
        "title": "Ace Cashmere Beanie",
        "price": "12.88"
      }
    ]
  }
}
```

**Output**

```html
Ace Cashmere Beanie
Fit 3 Denim Shirt
```

## uniq

`array | uniq`

Removes any duplicate items in an array.

**Code**

```liquid
{% assign random_number = '2,2,3,3,4' | split: ',' %}

{{ random_number | uniq | join: ',' }}
```

**Output**

```html
2,3,4
```
