# Wie sortiere ich das Custom Fields Field Array eines Produktes nach dem (key)

**URL:** https://forum.shopware.com/t/wie-sortiere-ich-das-custom-fields-field-array-eines-produktes-nach-dem-key/102759
**Category:** Programmierung
**Created:** [31. Januar 2024 um 14:32 UTC](https://forum.shopware.com/t/wie-sortiere-ich-das-custom-fields-field-array-eines-produktes-nach-dem-key/102759 "2024-01-31T14:32:40Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![jduMuc](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@jduMuc](https://forum.shopware.com/u/jduMuc)
#### Post date: [31. Januar 2024 um 14:32 UTC](https://forum.shopware.com/t/wie-sortiere-ich-das-custom-fields-field-array-eines-produktes-nach-dem-key/102759/1 "2024-01-31T14:32:40Z")

</div>

Wie kann ich die keys vorab im Array aufsteigend sortieren?

**Variante 1 (sort )**

Sortierung funktioniert leider nur auf value

{% for key, value in page.product.translated.customFields|sort %}

{{ key }} : {{ value }} 
  
{% endfor %}

**Variante 2 (keys|sort)**

Sortierung funktioniert auf key leider ohne value

{% for key in page.product.translated.customFields|keys|sort %}

{{ key }} : {{ value }} 
  
{% endfor %}

**Variante 3 (keys|sort)**

Sortierung funktioniert auf key und value, leider ist der key eine id und nicht der key wert

{% for key, value in page.product.translated.customFields|keys|sort %}

{{ key }} : {{ value }} 
  
{% endfor %}
