Working with Lists Errors

I’m building a game with a high scores list, and I can’t seem to get the the high score inputed into the right part of the list.

Here’s the problem replicated in a new app.
In this app, just make sure you click on the label to add the items to the list.

Then try adding in numbers, and you’ll soon realize the numbers are not being added in the correct spot. I’m wondering if the first occurrence of item block is the problem.

I’ve also tried without using first occurrence block and get the same error:

I’m not sure if on the backend it is looking at these numbers as a string instead of integers. Because of that it is thinking that the first number in a 2 digit number is the one that it compares…

Hey @liberteacher,

Any chance you have the points and name variables the wrong way around here?

Just checked again and no luck and I made sure.
Here’s the same project with the variable renamed as list.

I think it has something to do with getting the number from the list.

Thanks for looking in to this!

Are you sure you want to use the TextInput changes block here? This means that if you enter a two digit number the cloud points variable will change twice…three times for 3-digit numbers, and so on.

Can you clarify this part please. i.e:

“When the game ends I want the score to be added to the end of the list”


“When the game ends, the score should be inserted in numerical order into the list”


Thanks! :+1:

The “When text input changes” is just used for testing purposes. In the game it it triggers when the lives = 0.
To clarify, I’d like the number to be added to the list in order from greatest to least.
Thank you!

Thanks for clarifying. Ok, so for this:

You’d need to break it down into two steps.

  1. Add the score to the list
  2. Sort the scores in descending order.

One more question - will you need to get player names to go with the scores too? (this will complicate things slightly!)

1 Like