# Sorting list problem

**URL:** <https://community.thunkable.com/t/sorting-list-problem/1187224>\
**Category:** Questions about Thunkable X\
**Tags:** solved, beginner\
**Created:** [March 25, 2021, 8:54pm UTC](https://community.thunkable.com/t/sorting-list-problem/1187224 "2021-03-25T20:54:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![marketandsellbuy8jcb](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@marketandsellbuy8jcb](https://community.thunkable.com/u/marketandsellbuy8jcb)\
**Post date:** [March 25, 2021, 8:54pm UTC](https://community.thunkable.com/t/sorting-list-problem/1187224/1 "2021-03-25T20:54:47Z")

</div>

please i want sort list and make index list (1 ,2 ,3,…)  
as photo below (the sort pending on survey and don’t index but the list be  
4  
california

2  
newyork  
(where can i put sort block in this photo)  
…  
So thanks

 ![sort problem](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/7/7736bc3a90ccee9dcc759af1b68457834095b65a.png)

---

<div class="post-metadata">

**Author:** ![jane](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jane/32/27575_2.png) [@jane](https://community.thunkable.com/u/jane)\
**Post date:** [March 26, 2021, 1:21pm UTC](https://community.thunkable.com/t/sorting-list-problem/1187224/2 "2021-03-26T13:21:43Z")

</div>

Hi there,

Since you have indexes as properties in your object, this can be done pretty easily!

Start by creating a list of empty objects which is the same length as your list of unsorted objects.  
The, for each item in your list of unsorted objects, simply place them at their index position in this new list!  
You can see blocks to do this below:

 ![Screen Shot 2021-03-26 at 1.15.21 PM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/3/a3be09a34ec64a4d762da2e1e49e1b213a424efc.png)

You can view a project which uses this sorting method [here](https://x.thunkable.com/projectPage/605ddb3356c74c001236ec60/).

You can remix this project and try it out with different lists of objects in `ObjectList` and different amount of Labels on the screen.

This app assumes that:

- There are at least as many items in your `objectList` as there are labels on the screen. If you have 3 items in list, bur 4 labels, one of the labels will show `undefined`.
- Your `index` values on each object in your `objectList` are 1) unique values and 2) do not exceed the length of your list. For example, if your list has 7 objects, but one of the objects has an `index` value of 8, this sort function won’t work since there won’t be a position #8 on your `sortedList` to insert this object.

---

<div class="post-metadata">

**Author:** ![marketandsellbuy8jcb](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@marketandsellbuy8jcb](https://community.thunkable.com/u/marketandsellbuy8jcb)\
**Post date:** [March 26, 2021, 6:28pm UTC](https://community.thunkable.com/t/sorting-list-problem/1187224/3 "2021-03-26T18:28:42Z")

</div>

its awesome  
this make sorting  
i want also add index or series (1,2,3,…) to sorting list.

---

<div class="post-metadata">

**Author:** ![marketandsellbuy8jcb](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@marketandsellbuy8jcb](https://community.thunkable.com/u/marketandsellbuy8jcb)\
**Post date:** [April 2, 2021, 7:05pm UTC](https://community.thunkable.com/t/sorting-list-problem/1187224/4 "2021-04-02T19:05:50Z")

</div>

Thx  
i do it  
merge two list (index list) & (sorting list)

---

<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:25pm UTC](https://community.thunkable.com/t/sorting-list-problem/1187224/5 "2024-11-08T13:25:42Z")

</div>


