# Stackable List Order

**URL:** <https://community.weweb.io/t/stackable-list-order/6929>\
**Category:** Ask us anything\
**Created:** [February 9, 2024, 12:24am UTC](https://community.weweb.io/t/stackable-list-order/6929 "2024-02-09T00:24:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mark](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/mark/32/4163_2.png) [@mark](https://community.weweb.io/u/mark)\
**Post date:** [February 9, 2024, 12:24am UTC](https://community.weweb.io/t/stackable-list-order/6929/1 "2024-02-09T00:24:54Z")

</div>

Hi, I am using the Stackable List element and I want to run a loop in a workflow that updates the ‘order’ field of each object to match their index number in the list, Basically logging the order of the objects in the list after they have been re-arranged.

I’m not seeing a way of setting the objects in the list as an array. Whats the best method to update the order of the objects in the database to match their index in the list?

---

<div class="post-metadata">

**Author:** ![Sergio](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@Sergio](https://community.weweb.io/u/Sergio)\
**Post date:** [February 13, 2024, 11:45am UTC](https://community.weweb.io/t/stackable-list-order/6929/2 "2024-02-13T11:45:19Z")

</div>

How I solved this is by replacing all elements of the array using some JavaScript to update the “order\_no” key with the actual position of the list.  
The updated List is provided as Event Output in the Stackable Element.

Here is the setup and code:

![Screenshot 2024-02-13 at 12.40.34](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/6/6bdc36a360b11988ce6c5f9f51b59b0d2ff9dc8b.png)

var updated\_list = event?.[‘updatedList’];

for (let i = 0; i \< updated\_list.length; i++) {  
updated\_list[i].order\_no = i;  
}  
return updated\_list
