Iterate List in Reverse

  
Hi,

Is there a way I could do a forEach loop in reverse order starting from the end back to the first record?


Thanks,
Gino
there are ways.

question is more, since list normally come via a query, it's easy to fix it there.
set the "order by"

if that is not the case, I assume you build the list yourself, then I suggest instead of ListAppend, do a ListInsert at 0.

if that is also not the case, I suggest to take a look at SortRecordList.



Statler & Waldorf and the amazing flappy tweedles! wrote:
there are ways.

question is more, since list normally come via a query, it's easy to fix it there.
set the "order by"

if that is not the case, I assume you build the list yourself, then I suggest instead of ListAppend, do a ListInsert at 0.

if that is also not the case, I suggest to take a look at SortRecordList.


 
 
 I'll take a look at SortRecordList. Thanks!


Gino
Hi Gino,

If you need to iterate through the list in reverse but then for, some reason, still need the list to be in the initial order you can do a "while loop" using an "IF" condition to control it, something like this:

Hope it helps,
Hermínio Mira
Hermínio Mira wrote:
Hi Gino,

If you need to iterate through the list in reverse but then for, some reason, still need the list to be in the initial order you can do a "while loop" using an "IF" condition to control it, something like this:

Hope it helps,
Hermínio Mira
 
 Thanks Herminio for the additional tip :)


Regards,
Gino