Store top 5 score in an online database, If the users score a high score which overwrite one of the 5 highest score replace, update the top 5 score

image

image Hi, I have struggling for a few days with the app inventor. I have created a simple games and I wanted to store the top 5 score, if the users score a high score which overwrite one of the 5 high score I should replace update the top 5 score. The above is the blocks regarding the storing and updating of top 5 score, I don't know what is doesn't work as I expect. Could anyone give a help please I would appreciate it.

Welcome CW
This recent conversation might help you solve your issue How to Keep Top Scores in CloudDB via TagList

1 Like

Welcome,

When you add new score to list, you always need to sort them, and store the top five. This is what the strategy you need to follow.

1 Like

I'm sorting with this way but it doesn't work, it will replace all the score with the highest score instead of sorting it.

a7f359fea4e9ca1eeb99240ff86111aee4d50eac 926160c5fcef8346dc296302e619c21526d255d8_2_404x500

That AppendValueToList block looks wrong.

If the value under tag scorelist is a simple list of scores, why would you want to add a single element consisting of the entire scorelist to it?
Isn't that what the append block does?

AppendValueToList( tag , itemToAdd )

Append a value to the end of a list atomically. If two devices use this function simultaneously, both will be appended and no data lost.

![image|579x383]imageimage I'm so sorry I'm a really beginner to the app inventor, I have changed it to this. And the sort procedure for testing purpose I just do for index 4 and index 5 and what the result is instead of updating the new high score to index 4 and set the old lower score to index 5, it updates both index 4 and index 5 to the latest high score.