I am trying to develop a very simple game, where my students can solve 3 electrical problems, and then I will save the total time and the name of the student in a cloud database (firebase). Also, to encourage them, I want to show a ranking table (A Hall of Fame), with the fastest top 10 (and the very top 5 will receive a reward).
Save the user and the result of all users in the cloud is not a problem, I am using firebase. But I am having very serious problems to get the results from firebase to appinventor and sort them. I don´t find any block or other easy thing to do in appinventor.
As I am desesperate, I decided to create a webpage, for adding it to the app, with css code, to sort the results… but… the format of the values that appinventor upload to firebase is a little bit strange, because appinventor add a pair of " " in each side of the word, and I can´t work with them in order to sort them.
I spent two days through internet trying to find a solution, and I realised that a lot of people ask for the same question, but nobody has a solution (or I didn´t find it), and people that solved it ask for money, and I think that it has to be something free to everybody. Because if I want to use this for learning purposes this feature is an esential one.
When you save "numbers" from AI2 to Firebase, they are given the escaped double quotes, which turns the "number" into a "text number". When AI2 calls back the "number", it gets it as a "text number", so when sorting you get 1,10,2,... instead of 1,2,10.... You have some approaches to handle this.
On call back you can use a math multiply block to multiply the "text number" by 1 to convert it to a number.
On call back you can use a small procedure from Taifun to add leading zeros to each "text number", in order to be able to sort them lexicographically (alphabetically).
Hi Tim! Thank you very much for your answer, I decided to try sorting the results using an script in a webpage (https://runik.1mb.dev/), but I am finding with the problem of double quotes with numbers in firebase. At the end of your post, you said that “numbers in firebase are usually stored without any quotes at all”, but in my firebase they have double quotes, I show you my code in appinventor and the result in Firebase, what am I doing wrong?
You are not doing anything wrong, that is how the AI2 firebase component stores “numbers” in firebase (most other systems that can feed firebase will store texts in quotes, and numbers without quotes), the problem is that they come back as “text numbers”, therefore more work is required (as indicated above) to get them back to being numbers. This is my experience.