---
title: 'Liquid filters: sort'
description: >-
  Sorts the items in an array in case-sensitive alphabetical, or numerical,
  order.
source_url:
  html: 'https://shopify.dev/docs/api/liquid/filters/sort'
  md: 'https://shopify.dev/docs/api/liquid/filters/sort.md'
api_name: liquid
---

# sort

```oobleck
array | sort
```

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

##### Code

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

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

##### Data

```json
{
  "collection": {
    "all_tags": [
      "Burning",
      "dried",
      "extra-potent",
      "extracts",
      "fresh",
      "healing",
      "ingredients",
      "music",
      "plant",
      "Salty",
      "supplies"
    ]
  }
}
```

##### Output

```html
Burning
Salty
dried
extra-potent
extracts
fresh
healing
ingredients
music
plant
supplies
```

### Sort by an array item property

```oobleck
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": [
      {
        "price": 1000,
        "title": "Blue Mountain Flower"
      },
      {
        "price": 0,
        "title": "Charcoal"
      },
      {
        "price": 5600,
        "title": "Crocodile tears"
      },
      {
        "price": 0,
        "title": "Dandelion milk"
      },
      {
        "price": 100000000,
        "title": "Draught of Immortality"
      },
      {
        "price": 898,
        "title": "Dried chamomile"
      },
      {
        "price": 0,
        "title": "Forest mushroom"
      },
      {
        "price": 1000,
        "title": "Gift Card"
      },
      {
        "price": 0,
        "title": "Glacier ice"
      },
      {
        "price": 0,
        "title": "Ground mandrake root"
      },
      {
        "price": 1000,
        "title": "Health potion"
      },
      {
        "price": 25000,
        "title": "Invisibility potion"
      },
      {
        "price": 0,
        "title": "Komodo dragon scale"
      },
      {
        "price": 0,
        "title": "Love Potion"
      },
      {
        "price": 1000,
        "title": "Mana potion"
      },
      {
        "price": 0,
        "title": "Potion beats"
      },
      {
        "price": 0,
        "title": "Potion bottle"
      },
      {
        "price": 40000,
        "title": "Viper venom"
      },
      {
        "price": 2499,
        "title": "Whole bloodroot"
      }
    ]
  }
}
```

##### Output

```html
Charcoal
Dandelion milk
Forest mushroom
Glacier ice
Ground mandrake root
Komodo dragon scale
Love Potion
Potion beats
Potion bottle
Dried chamomile
Blue Mountain Flower
Gift Card
Health potion
Mana potion
Whole bloodroot
Crocodile tears
Invisibility potion
Viper venom
Draught of Immortality
```
