Hello friend, today I am going to share a method with you so that you can arrange the list in ascending or descending order without any extension in kodular or any app inventor.
Read the full guide to understand what happened
Creating Variable
Before that, we have to create some variables-
Main List- The value will be stored in the list after ascending and descending order.
Temp List - In this, we will store the value temporarily.
Temp List2- In this, we will store the value temporarily.
Leaderboard Name- Name of players
Leaderboard Points- Score of players
Temp Name- Name of players again
Temp Points- Score of players again
Storing values to list.
Right now I am storing the data in firebase. And calling it again from firebase. This helps you to know about storing data and receiving data from firebase.
After that, we will store the data in the list. Store the data you want in separate lists.
Leaderboard Name- Name of players
Leaderboard Points- Score of players
Temp Name- Name of players again
Temp Points- Score of players again
Storing data takes time and without delay, it causes errors. So, I am using a clock component for causing a 20-millisecond delay.
This will make sure that if all the values are stored properly then the next function will happen.
From the following block, I wanted to check whether the list call has happened or not. Everything, I wanted is in place or not.
Sorting starts here
Now from here, we will start sorting the list. If you want to sort any list, put numbers in Temporary List 2.
The block is given above. First of all, we have created a temporary list as an empty list. After this, we connected two different for-each-number components to the same list. In which we remove the value by using the if-then component if both have the same value.
Then we use the if-then component to add the higher value to the temporary list which
we had made an empty list earlier.
The value which is in the Temporary List 2 [not in the Temporary List]. That is the smallest value. So we will store it in the main list.
But before that, I stored the value in a text. And then run a timer (with the help of Clock Component)of 10 milliseconds. This gives sufficient time for storing the values in the list.
When we will store that value in the main list with the help of text. Then we remove it from Temporary List 2.
Now we will convert this whole process into a loop using the if-then component. This loop will continue until the length of the main list is get equal to the length of the list containing the leaderboard points.
And then we will display the value of the main list with the help of the listview component which we stored and sorted into ascending order.
If you need this list in descending order, just reverse it by using the reverse list component.
3 Comments
Hey anyone have question; Ask here.
ReplyDeleteaia? please
ReplyDeletehttps://drive.google.com/u/0/uc?id=1gB2_F8z1G8MMOLQ5KHrO7hJGEIGCwt5R&export=download
Delete