# Sort a Cloudlist with child

**URL:** https://community.thunkable.com/t/sort-a-cloudlist-with-child/1096418
**Category:** Questions about Thunkable X
**Tags:** firebase
**Created:** [February 14, 2021, 9:44pm UTC](https://community.thunkable.com/t/sort-a-cloudlist-with-child/1096418 "2021-02-14T21:44:54Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [February 14, 2021, 9:44pm UTC](https://community.thunkable.com/t/sort-a-cloudlist-with-child/1096418/1 "2021-02-14T21:44:54Z")

</div>

Hi all.  
I have a problem when I delete a child (2 in this case should be at the blue mark) The app crashes becaus number 2 now is missing.  
How can I sort this list again so the list from 0 to 4 is complete.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/0/70900a958ce1be20eff61e76c17f1ab9fe353ebd.png)

---

<div class="post-metadata">

### Author: ![Deluxe](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/deluxe/32/30016_2.png) [@Deluxe](https://community.thunkable.com/u/Deluxe)
#### Post date: [February 15, 2021, 8:20am UTC](https://community.thunkable.com/t/sort-a-cloudlist-with-child/1096418/2 "2021-02-15T08:20:03Z")

</div>

Ooohhh that’s a gooooood question! Let’s see if anyone has an answer because I am sure that sooner all later we will all come across this issue.

But let me ask this, are you using a “for” loop to iterate through the array or are you using the “for each” loop?

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [February 15, 2021, 9:28am UTC](https://community.thunkable.com/t/sort-a-cloudlist-with-child/1096418/3 "2021-02-15T09:28:27Z")

</div>

If you retrieve your list using something like this  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/9/290dd8576d44ddaf087c8505b60f1ff149770f32.png)

The `objList` will be a list of the numbers of your objects. Then you need to go thorough the list using the foor each loop  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/2/42bcda451b80ab763e991ca670571a991862773b.png)

This will allow you to go through your data regardless of the numbers being sequential or not.

---

<div class="post-metadata">

### Author: ![funhall](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/funhall/32/92145_2.png) [@funhall](https://community.thunkable.com/u/funhall)
#### Post date: [February 15, 2021, 3:50pm UTC](https://community.thunkable.com/t/sort-a-cloudlist-with-child/1096418/4 "2021-02-15T15:50:31Z")

</div>

Thanks for the ideer, that schould work yes. But there is a problem.  
This is what I try it your way:  
And this don’t work.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/2/42838d564bd738f8f868debd29b286de40462d3b.png)  
But this below work fine.  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/6/d661122e769cce14229e1e9f81bbbf8b29123fe9.png)  
Here is the DB  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/6/d61d6503ab09b103347a7fc35bcae77774fdebf2.png)

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 1:29pm UTC](https://community.thunkable.com/t/sort-a-cloudlist-with-child/1096418/5 "2024-11-08T13:29:26Z")

</div>


