I’m attempting to sort my array by the value of my order field in my metaobject. For example, each brand entry has brand.order which is an integer. How can i access these values and sort them before my for loop runs?
{% assign sorted_brands = shop.metaobjects.brands.values | sort: 'order' %}
{% for brand in sorted_brands %}
{% if brand.category == category %}
<li class="flex items-center justify-center">
<a href="{{ brand.url }}" target="_blank" class="max-h-[44px] w-auto flex items-center justify-center">
<img
srcset="{{ brand.logo.value | image_url }}"
src="{{ brand.logo.value | image_url }}"
alt="{{ brand.name }}"
height="44"
width="86"
class="max-h-[44px] w-auto"
loading="lazy"
>
</a>
</li>
{% endif %}
{% endfor %}