# \[Solved\] Can you compare Text Variables? (Selection Sorting by Title)

**URL:** <https://community.thunkable.com/t/solved-can-you-compare-text-variables-selection-sorting-by-title/1626214>\
**Category:** Questions about Thunkable X\
**Tags:** solved\
**Created:** [November 20, 2021, 5:36pm UTC](https://community.thunkable.com/t/solved-can-you-compare-text-variables-selection-sorting-by-title/1626214 "2021-11-20T17:36:37Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![divakard17u](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/divakard17u/32/118358_2.png) [@divakard17u](https://community.thunkable.com/u/divakard17u)\
**Post date:** [November 20, 2021, 5:36pm UTC](https://community.thunkable.com/t/solved-can-you-compare-text-variables-selection-sorting-by-title/1626214/1 "2021-11-20T17:36:37Z")

</div>

![Screenshot 2021-11-21 at 1.39.33 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/f/8fcf88c6499abd00f2d1403854cc38ba39ccba08.png)

Hello! I’m new to Thunkable and I wanted to know whether you are able to compare Text Variables with each other - (For Eg **if A\>B then print A** ). My above code isn’t working. I’m trying to sort a list using _selection sort_ according to the title in _ascending order_ (For eg. **Base, Cake, Area** -----\> sorts to **Area, Base, Cake** ) which I will then run into a Binary Search Function with an input.  
Please guide me as to where I’m going wrong. Thank you!  
Again, thank you for your help! I really appreciate it 🙂

---

<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:** [November 20, 2021, 5:43pm UTC](https://community.thunkable.com/t/solved-can-you-compare-text-variables-selection-sorting-by-title/1626214/2 "2021-11-20T17:43:35Z")

</div>

Welcome to Thunkable.

Text is text and is not converted to ASCII value so **A+1** will become **A1** and due to the fact that the loop is expecting a number it will fail an nothing will get executed inside the loop block.

Sorting values inside a list is done by the `sort` block in the `Lists` drawer. You do not need any code to do that.

---

<div class="post-metadata">

**Author:** ![divakard17u](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/divakard17u/32/118358_2.png) [@divakard17u](https://community.thunkable.com/u/divakard17u)\
**Post date:** [November 20, 2021, 5:48pm UTC](https://community.thunkable.com/t/solved-can-you-compare-text-variables-selection-sorting-by-title/1626214/3 "2021-11-20T17:48:58Z")

</div>

Thank you so much for replying @muneer !  
I’m actually doing a project for my CS Class - was trying to implement a proper code for sorting (for complexity points 😄 ).  
Is there any way to compare Text Variables in Thunkable?

ps - Happy Birthday to you!

---

<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:** [November 20, 2021, 6:10pm UTC](https://community.thunkable.com/t/solved-can-you-compare-text-variables-selection-sorting-by-title/1626214/4 "2021-11-20T18:10:30Z")

</div>

This is a project I did to demo sorting complex objects. See if it helps you.

[https://x.thunkable.com/projectPage/60d78e2a5e21e600110b78b4](https://x.thunkable.com/projectPage/60d78e2a5e21e600110b78b4)

---

<div class="post-metadata">

**Author:** ![divakard17u](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/divakard17u/32/118358_2.png) [@divakard17u](https://community.thunkable.com/u/divakard17u)\
**Post date:** [November 20, 2021, 6:27pm UTC](https://community.thunkable.com/t/solved-can-you-compare-text-variables-selection-sorting-by-title/1626214/5 "2021-11-20T18:27:01Z")

</div>

Thanks for the project link! Just went through it. Saw you sorted it through _Value 1_ (which holds integers)

Just wanted to know if Text Variables can be compared somehow. For example -

**If A\>B**  
**Print A**

how would I code this in Thunkable? I felt like _comparing Text Variables_ should be a feature.

---

<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:** [November 20, 2021, 6:33pm UTC](https://community.thunkable.com/t/solved-can-you-compare-text-variables-selection-sorting-by-title/1626214/6 "2021-11-20T18:33:12Z")

</div>

> [@divakard17u](#):
>
> wanted to know if Text Variables can be compared

Yes you can. In my project I’m comparing values but if you replace the values with letters it will work for you the same way.

Just remember one thing. In text comparison it is taken position by position not he whole string with the whole string so even the letter case (Small or Caps) will make a difference.

Try this  
[https://x.thunkable.com/projectPage/6103dec760c70500ef73d4b0](https://x.thunkable.com/projectPage/6103dec760c70500ef73d4b0)

This is sorting text from a table and display them in order. It should give you want you want.

---

<div class="post-metadata">

**Author:** ![divakard17u](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/divakard17u/32/118358_2.png) [@divakard17u](https://community.thunkable.com/u/divakard17u)\
**Post date:** [November 20, 2021, 6:36pm UTC](https://community.thunkable.com/t/solved-can-you-compare-text-variables-selection-sorting-by-title/1626214/7 "2021-11-20T18:36:47Z")

</div>

Sure thing! I will go through this!  
Thank you so much for your time @muneer!

Happy Birthday! and Hope you have a Long and Happy life!

---

<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:** [November 20, 2021, 6:38pm UTC](https://community.thunkable.com/t/solved-can-you-compare-text-variables-selection-sorting-by-title/1626214/8 "2021-11-20T18:38:42Z")

</div>

> [@divakard17u](#):
>
> Happy Birthday! and Hope you have a Long and Happy life!

Thank you

---

<div class="post-metadata">

**Author:** ![divakard17u](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/divakard17u/32/118358_2.png) [@divakard17u](https://community.thunkable.com/u/divakard17u)\
**Post date:** [November 21, 2021, 2:26am UTC](https://community.thunkable.com/t/solved-can-you-compare-text-variables-selection-sorting-by-title/1626214/9 "2021-11-21T02:26:52Z")

</div>

> [@muneer](#):
>
> whole string so even the letter case _(Small or Caps) will make a difference._

This seemed to have been the problem in my code, furthermore, somehow the number of rows in my database turned out to be 14, but I have only 6 values in my database (seems like a bug). Also I put _insert at_ in the list increasing the list size and bloating my outcome. Thank you for your help!

---

<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:** [November 21, 2021, 3:52am UTC](https://community.thunkable.com/t/solved-can-you-compare-text-variables-selection-sorting-by-title/1626214/10 "2021-11-21T03:52:21Z")

</div>

If you can share the link to your project to look into the code or share images of your code?

---

<div class="post-metadata">

**Author:** ![divakard17u](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/divakard17u/32/118358_2.png) [@divakard17u](https://community.thunkable.com/u/divakard17u)\
**Post date:** [November 21, 2021, 5:02am UTC](https://community.thunkable.com/t/solved-can-you-compare-text-variables-selection-sorting-by-title/1626214/11 "2021-11-21T05:02:57Z")

</div>

I really can’t do that I’m so sorry 😅. This project is graded, So sharing the link would make my project come under scrutiny on the grounds of ‘Integrity of code’. I can take some guidance, but that’s about it.

But I think I fixed the _ **Length of the List is 14** _ issue by adding actual 14 values (From then on the counting, seemed to resolve perfectly fine) -

For Example now if I add a value in the database (DB), the length list of values goes From 14 to 15.

Before, if I had, say, 7 values in DB and I add one more value to make it 8 values in the database, the Length of the list of values in DB would stay at 14, funny enough. Any values in the database below 14, the Length of the list in DB came out to be 14 and didn’t budge. (Probably is a rare bug, I’m not sure.) (I’m using Google Sheets as DB)

The sorting now works! 😁Extremely Happy, but it takes quite some time to compute (understandably) on the Live View of the App on the phone. So, I’ll probably make this compute only once, then store the sort using stored variables! But your guidance helped me a lot! I can’t stress that enough! Thank you so much @muneer

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)\
**Post date:** [February 19, 2022, 5:03am UTC](https://community.thunkable.com/t/solved-can-you-compare-text-variables-selection-sorting-by-title/1626214/12 "2022-02-19T05:03:43Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
