Skip to content

Sort Key ​

Sorts an object by its keys.

Example ​

Data
json
{
  "options": {
    "size": "M",
    "color": "red",
    "material": "cotton"
  }
}
liquid
{% assign options = options | sort_key %}
{% for option in options %}
  {{- option[0] }}: {{ option[1] }}
{% endfor %}

Output

html
color: red
material: cotton
size: M