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
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.
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!
This is a project I did to demo sorting complex objects. See if it helps you.
https://x.thunkable.com/projectPage/60d78e2a5e21e600110b78b4
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.
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
This is sorting text from a table and display them in order. It should give you want you want.
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!
Thank you
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!
If you can share the link to your project to look into the code or share images of your code?
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
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.