(sos!) Help me fix some problem for my Sorting (name and score)

I believe is a matter of timing when you update your ListScores, save data to CloudDB and get it back

sorry, i dont understand. Do u mind to explain detail

1 Like


i got the descending order(but i actually need ascending for the only 5 highest score based on the requirement): haha


if use the top5 block, also got the same result. Is there any ideas to limit it to show 5 highest score only

image

With your blocks sequence you get top 5 and then add 0 to list so you have 6 items. Move procedure above set ListView elements

1 Like

Hi, thanks for helping me solve all the problems I encountered. Finally, I've got the results for the top 5 highest scores.

do u think my lecturer wants me to sort the score from highest to lowest /or/ lowest to highest score? This is the requirement mention by him:
-The mobile app shall let the users enter their name if their score is high and going to overwrite one of the 5 highest scores.
-The mobile app shall be able to display the top 5 highest scores in an ascending order

But I feel it is kind of weird if I sort the lowest to highest score order hahha, it doesn't make sense to me

Thanks for helping me, finally i got the result I want :laughing:


can i ask why this doesnt show up the only 5 highest score, instead it show more than 5

Do you see a 5 in any of the logic in those blocks?
(oops , I see it now.)

All it does is sort .
But it does not remove any list items, and it does not try to copy only 5 items to a new list.

P.S. I gave you a separate value procedure that takes the first 5 items of a list earlier.

It is simpler to separate those two processes

  • sorting
  • trimming
    to separate processes.

It's like trying to run while putting on your shoes. You will fall on your face.

For my original procedure(the one i used insertion sort), is it possible to edit it to meet the 5 highest score only to show up

can i ask is this consider Insertion Sort Algorithm /or/ selection /or/ bubble

bubble sort

1 Like

Yes.

After calling the procedure to sort the global high score list in place,
add extra blocks to
set global high scores list to call top5(global high scores list)

1 Like

All in one procedure sort list - get x items - choose ascending/descending order. Blocks draggable

image

1 Like

The order is important.

  • Get the old list
  • add the new score
  • sort the expanded list
  • clip the sorted list to length
  • store the clipped sorted list back in CloudDB
1 Like

can i ask which sorting method is this? is bubble?

Yes

1 Like

tq so much u all are so helpful

1 Like