Hey everyone,
I'm working on a leaderboard in Construct 3 where I store team names and their scores in an array. I’ve already managed to correctly insert the data into the array and display it in a list, but now I’m trying to sort the leaderboard so the team with the highest score appears at the top.
I’m using a comparison-based sorting algorithm to swap the values in the array, but I’m running into some issues. I’ve set up a loop to compare the values and swap them, but I can’t seem to get it to work properly. Here are the issues I’m facing:
The leaderboard isn’t being sorted correctly. Some values are duplicated, and the team with the highest score isn’t appearing at the top.
I’m using a nested loop to compare and swap the values, but I can’t get it to work without duplicating or showing the wrong results.
I’ve attached an image of my current code. If anyone has any advice on how I can improve this sorting process or what I might be doing wrong, I’d really appreciate it!
My code:
What I got: