Skip to main content
Solved

How would I sort an array?

  • October 25, 2024
  • 2 replies
  • 23 views

Forum|alt.badge.img+3
  • Contributor I
  • 1 reply

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 %}

 

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,

View original
Did this topic or the replies in the thread help you find an answer to your question?

2 replies

Forum|alt.badge.img+3
  • Author
  • Contributor I
  • 1 reply
  • October 25, 2024

testing to make sure this thing is on. 


ArpitBanjara
Principal User I
Forum|alt.badge.img+36
  • Principal User I
  • 371 replies
  • Answer
  • 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,