# How to compare two list?

**URL:** <https://community.thunkable.com/t/how-to-compare-two-list/367789>\
**Category:** Questions about Thunkable X\
**Created:** [December 14, 2019, 3:21pm UTC](https://community.thunkable.com/t/how-to-compare-two-list/367789 "2019-12-14T15:21:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![test.0987.saveut](https://avatars.discourse-cdn.com/v4/letter/t/58f4c7/32.png) [@test.0987.saveut](https://community.thunkable.com/u/test.0987.saveut)\
**Post date:** [December 14, 2019, 3:21pm UTC](https://community.thunkable.com/t/how-to-compare-two-list/367789/1 "2019-12-14T15:21:27Z")

</div>

Example as  
List1 = 1,2,3,4  
List2 = 4,3,2,1  
List3 = 1,2,3,4

List1 != List2  
List1 = List3  
I want to compare both num and location in list, how do I do this?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 14, 2019, 6:17pm UTC](https://community.thunkable.com/t/how-to-compare-two-list/367789/2 "2019-12-14T18:17:15Z")

</div>

There is no built-in way to compare full lists. You’d have to use a loop to check each item against the other list.

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [December 14, 2019, 6:22pm UTC](https://community.thunkable.com/t/how-to-compare-two-list/367789/3 "2019-12-14T18:22:49Z")

</div>

To solve your problem, you need to convert lists to strings (text) and compare strings.

![изображение](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/7/c7eabc3603600a25f4447a14211e1125fc92cfcf.png)

Best regards, Alex  
[ACtech demo project](https://x.thunkable.com/projects/5d70f93f8a62b4079eedaff2/project/properties/designer/)  
[Thunkable X Basic Programming Course](http://droidscript.ru/main/title_ds15.php)  
[Block Reference](http://droidscript.ru/main/statyi/thunkableios_blockhelper.php)  
[Component Reference](http://droidscript.ru/main/statyi/thunkableios_objects.php)  
[Bug tracker](https://x.thunkable.com/projects/5dbd5243a77acad1b26f851f/project/properties/designer/)  
[Polipaint](https://x.thunkable.com/projects/5db56632a1e1fcefd3932db7/project/properties/designer/)  
[Map canvas](https://x.thunkable.com/projects/5db56eadb7c037443fadb222/project/properties/designer/)  
[Method Inspector](https://x.thunkable.com/projects/5d9310fcdf0a8f208bd2bb11/openProject/designer)  
[Performance](https://x.thunkable.com/projects/5db93ebab8e0fc9c685b3477/project/properties/designer/)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 14, 2019, 6:28pm UTC](https://community.thunkable.com/t/how-to-compare-two-list/367789/4 "2019-12-14T18:28:07Z")

</div>

@actech Smart! Is there a length limit to strings in Thunkable? I could see that conversion working for a list with small values (1 to 4) but I’m wondering about something that uses longer numbers (1000 to 4000).

---

<div class="post-metadata">

**Author:** ![actech](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@actech](https://community.thunkable.com/u/actech)\
**Post date:** [December 14, 2019, 6:31pm UTC](https://community.thunkable.com/t/how-to-compare-two-list/367789/5 "2019-12-14T18:31:22Z")

</div>

I work with lists that consist of several tens of thousands of records and without any problems convert them to strings and vice versa.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [December 14, 2019, 7:08pm UTC](https://community.thunkable.com/t/how-to-compare-two-list/367789/6 "2019-12-14T19:08:50Z")

</div>

Here’s a demo of what @actech described: [https://x.thunkable.com/copy/c13472b100564cdf35d3d5a4c28326ff](https://x.thunkable.com/copy/c13472b100564cdf35d3d5a4c28326ff)

---

<div class="post-metadata">

**Author:** ![CBVG](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/cbvg/32/32401_2.png) [@CBVG](https://community.thunkable.com/u/CBVG)\
**Post date:** [December 15, 2019, 12:51am UTC](https://community.thunkable.com/t/how-to-compare-two-list/367789/7 "2019-12-15T00:51:53Z")

</div>

Do this:

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/4/24d22b5266b8211c0c7dbc03e5ed022400040328.png)

with this, the result of “compare\_lists(List1,List2)” would be ‘false’, while “compare\_lists(List1,List3)” would return ‘true’.

The strength of this approach is that lists of different length are immediately reported as not being the same, and that the comparison of elements stops as soon as there is one mismatch. Only in the case of identical lists would all the elements be checked one against one.

---

<div class="post-metadata">

**Author:** ![test.0987.saveut](https://avatars.discourse-cdn.com/v4/letter/t/58f4c7/32.png) [@test.0987.saveut](https://community.thunkable.com/u/test.0987.saveut)\
**Post date:** [December 15, 2019, 8:15am UTC](https://community.thunkable.com/t/how-to-compare-two-list/367789/8 "2019-12-15T08:15:59Z")

</div>

Thanks

---

<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, 11:46am UTC](https://community.thunkable.com/t/how-to-compare-two-list/367789/9 "2024-11-08T11:46:24Z")

</div>


