Skip to main content
Contributor I
October 25, 2024
Solved

How would I sort an array?

  • October 25, 2024
  • 2 replies
  • 118 views

I have an array that I want to sort by expiration date. I’m getting mixed messages on if and how this can be done. I would love any guidance with this code. 

{% for reward in person.x_activeRewards %}
<div>
<p>{{ reward.expirationDate }}</p>
</div>
{% endfor %}

 

    This topic has been closed for replies.
    Best answer by ArpitBanjara

    Hey @Bryce 

    I am not 100% sure but can you try to use the ‘sort’ filter?

    something like this - {% assign sorted_rewards = person.x_activeRewards | sort: 'expirationDate' %}

     

    Let me know if this works

    Cheers,

    2 replies

    BryceAuthor
    Contributor I
    October 25, 2024

    testing to make sure this thing is on. 

    ArpitBanjara
    Principal User II
    Principal User II
    October 27, 2024

    Hey @Bryce 

    I am not 100% sure but can you try to use the ‘sort’ filter?

    something like this - {% assign sorted_rewards = person.x_activeRewards | sort: 'expirationDate' %}

     

    Let me know if this works

    Cheers,

    Arpit Banjara - Lead Email Marketing Specialist at Flowium