Float Thread sorting and order
I am using the fllowing REST Api to fetch the floating threads, i need them to be sorted and like the newest thread created to be on top.
/restapi/vc/categories/id/CAT-ID/subscriptions/global/float/thread
Thanks
If I understand correctly, you want to get a list of floated threads sorted by the date of the root post. In your sample code, it looks like you're sorting messages within a thread, rather than sorting the list of threads.
Here's a quick example of sorting the list of floated threads (community-wide) by the date of the root post (most recent first):
<#assign floated_threads = rest("/subscriptions/global/float/thread").subscriptions /> <#list floated_threads.subscription?sort_by(["target","messages","topic","post_time"])?reverse as subscription> ${subscription.target.messages.topic.id} - ${subscription.target.messages.topic.post_time} <br> </#list>
So basically I get the list of floated threads across the entire community, iterate through the list sorted in reverse order by post_time, and then output the id and date of the root post.
I want to point out that in this case the sort_by is taking a sequence of 4 values which correspond to the names of the nested subvariables. For example, the post_time of the root post as I'm looping through the subscriptions is accessible via "subscription.target.messages.topic.id", so my parameter for "sort_by" is the sequence "["target","messages","topic","post_time"]"
I hope this helps!