Sort array (highscores)

0 favourites
  • 3 posts
From the Asset Store
A master sorting Puzzle fun and addictive puzzle game! A challenging yet relaxing game to exercise your brain!
  • Hello again guys, please I need help because I use google firebase to host my points I store something like this in a global...

    Big Monk ----- 90 GREGORY ----- 150 Gabriela ----- 70 Karen ----- 90 L7iz ----- 170 Nevesbr ----- 110 You ----- 80 among us ----- 60 cheese ----- 70 harry 66 ----- 70 nate ----- 180 nobody ----- 100 pecinha ----- 80 veneza ----- 110

    So I threw this into an Array and got this:

    But I came across the problem of it not sending the largest point to the top...

    So using tokenat I removed the names and managed to organize the points but how am I going to show the points with names again to the player?

  • Change it to 2D array - set its height to 2. Then split the results with tokenat() moving the scores to Y0 and names to Y1.

    For "x" from 0 to array.width-1 
     
    .. // Extracting name 
    .. Array set at (loopindex, 1) value tokenat(self.at(loopindex,0), 1, " ----- ") 
     
    .. // Extracting score 
    .. Array set at (loopindex, 0) value tokenat(self.at(loopindex,0), 0, " ----- ") 
    

    After that if you sort the array, it will be sorted by scores.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Change it to 2D array - set its height to 2. Then split the results with tokenat() moving the scores to Y0 and names to Y1.

    > For "x" from 0 to array.width-1 
     
    .. // Extracting name 
    .. Array set at (loopindex, 1) value tokenat(self.at(loopindex,0), 1, " ----- ") 
     
    .. // Extracting score 
    .. Array set at (loopindex, 0) value tokenat(self.at(loopindex,0), 0, " ----- ") 
    

    After that if you sort the array, it will be sorted by scores.

    Very well thanks !

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)