Markdown Card For loop ordering?

I have a markdown card which is like this

{% for package in states.sensor.seventeentrack_packages_in_transit.attributes.packages %}
**{{ package.friendly_name }}:** {{ package.info_text }} is at {{package.location}}. The NZ Post link is [{{package.tracking_number}}](https://www.nzpost.co.nz/tools/tracking/item/{{package.tracking_number}}) 

{% endfor %}

This works great, but I would like to sort them by package.timestamp. Is there a way to do that? I have looked at the markdown docs and the templating docs, but I just don’t get it. (If it is possible at all).

Does


{% for package in states.sensor.seventeentrack_packages_in_transit.attributes.packages |sort(attribute='attributes.timestamp', reverse=true)%}

work with your sensor?

No, but I imagine it is not far off working, thanks. I’ll keep fidding. Should I be looking in the Jinja documentation perhaps?

Thank you so much for pointing me in the right direction. This works:


{% for package in states.sensor.seventeentrack_packages_in_transit.attributes.packages|sort (attribute='timestamp',reverse=true) %}