Hello koders. I’ve got a challenge for you. So basically in A I have a list I created myself ((4 brasil ronaldinho) (1 españa iniesta) (3 argentina messi) (2 francia henry)) - What I do want to do is that based on the first value of each item (4, 1, 3, 2) create a whole new list with that in order. I think I made it okey until point B where I achieve ordering the numbers with the bubblesort, and after that im lost. Any solution please?
P,S; I want the list to be ((1 españa iniesta) (2 francia henry) (3 messi argentina) (4 ronaldinho brasil))
Try list utilities extension ,
In my opinion, young man, this would be a great Algorithm learning exercise for You.
I also recommend you to use ListUtils extension. I am using List utilities extension in my every project.
It is one of the best extension!
Just use list utilities sort list block. Attach your list to this block and put sort order to 1.
I can’t find the extension by searching it here Where can I get it?
Thank you all for the help, I am already using the extension. Its really important for me to figure out this because I need this to finish my app. So I am pretty close.
First im taking the ranking out and put it in order, and then for each ranking if its contained of each item of the list, i ask to add it on a new list, but it adds the item in the same order and not following the ranking order as you can see it appears
((brasil) (España (argentina) (francia)) and it should be ((españa) (francia) (argentina) (brasil))
If someone can help I’d be very grateful
What an amazing Job dora, thank you very much.
You wont believe me… the sortlist only orders 10 items within a list, and my list contains 11 items. Do you know any way to solve this?
It works with more items with no problem .You should know that items are treated as strings so when you want to sort for example numbers , sorting is according to the first digit for example in a list 2,5,3,4,1,10,7,6,8,9 sorting will result as 1, 10, 2, 3, 4, 5, 6, 7, 8, 9 See example below
To overcome that problem all you have to add leading zeros to your numbers for example
Show where do you show the result of your list ? As element in a list view ?
Hey I appreciate a lot your answer. I tried to apply it to my app but I found another way. Would you tell me why the final result is not ((argentina) (brasil) (chile))? what shoud i modify in order to get to that?
There is a problem with your logic. You only sorted ascending OrdernandoDAscendente but indexing in global PaisesDesordenados remains the same
Actually when you use select list item list index 1 the order of your list is ((Chile 1072220452905) (Argentina 1072010499025) (Brazil 1072120458855)) - see image - so the result is ((Chile) (Argentina) (Brazil))
The procedure you created works like this. For each item in list ((Chile 1072220452905) (Argentina 1072010499025) (Brazil 1072120458855)) meaning
For each item in list (1072010499025 1072120458855 1072220452905)
check if contains text and if true add to list
So the hole procedure first checks if (Chile 1072220452905) contains 1072010499025 → result false nothing added to list then checks if (Chile 1072220452905) contains 1072120458855 → result false nothing added to list and then checks if (Chile 1072220452905) contains 1072220452905 → true.
So Chile (index 1) added to list and so on
Hope you understand
Hey, I am back, thanks for your solution - I can order the list. But now I can’t select the item Someone told me that the listutils does something that create empty variables, I really didn’t understand. Please take a look.
I don’t know what exactly you are trying to do but the
get item block is single item and not a list and hence if your passing it as parameter that requires list then it will obviously produce the error.
Well here the “item” does work as a list
why? what happens? and what about trying Do it?
also let me recommend to rename item to sublist…
use Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools
If you read above you will see what happens - To give you a quick summary, the first list is disordered, when i order it with list utils, then I can’t select list item
so are you using the solution from @dora_paz?
or are you still using listutils?
So why don’t you use the working solution from @dora_paz?
With dora_paz solution I was able to order the list (his solution involved the use of listutils), but not to select list item - So it’s a parcial solution because I need to select list item
I just need to do this (circled in blue)
For this ordered list without an error
I really don’t care about the lenght of the variable’s name, this is just a testing and what I care about is to be able to select list item as I did in the first picture (with the list disordered) but for the second picture (with the list ordered via listutils)
How global ordenalalistaenbaseid is populated ? Please show your blocks
In my example see how list is populated. I can select item 1 but the result is not a list so when I try to get item 1 from that I receive an error. If I wish to get item1 then I use split a spaces block to create a new list and then get item1