0

In my extension, I'm trying to sort a date array in ascending order:

<f:for each="{data_eventarray}" as="data_item">
 {data_item.data.eventdate}<br>
</f:if>

Output:

1645138800
1643756400
1643756400
1645052400
1660341600
1645657200
1646175600

Now I want to sort the numbers in ascending order:

1643756400
1643756400
1645052400
1645138800
1645657200
1646175600
1660341600 

I've already tried the following without success:

<f:for each="{data_eventarray -> v:iterator.sort(sortBy: '{data.eventdate}' order: 'ASC')}" as="data_item">
{data_item.data.eventdate}<br>
</f:if>

Can someone help me?

1 Answer 1

1

the sortByparamter of the v:iterator.sort VH needs to be an attribute name. You used a (in this context) not defined variable which would result in a string replacement, which is the same for all array items. so no sorting will occur.

try: (Braces removed)

<f:for each="{data_eventarray -> v:iterator.sort(sortBy: 'data.eventdate' order: 'ASC')}" as="data_item">
{data_item.data.eventdate}<br>
</f:if>

----
wrong parameter:  

    ... (sortBy:'{data.eventdate}' ...  

correct prameter:  

    ... (sortBy:'data.eventdate' ...

  
Sign up to request clarification or add additional context in comments.

1 Comment

{data.eventdate} is the number(date) in {data_enentarray}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.