title: Firebase - How to retrieve data and sort it to display in list?
body: <p>To give you some context: my project is a game and at the end of the game you can enter your Name and "submit" it to a leader-board. When submitting it's going to send your name and your global score to the Firebase. </p>
  
  <p>This far, I'm able to submit data but I'm having <strong>trouble to retrieve it AND sort it by that global score</strong> so that the <strong>Best player goes on top of list</strong> (which is the leaderboard).</p>
  
  <p>I'm using this to create my li in my ul:</p>
  
  <pre><code>function gotData(data){
  
    var scores =data.val();
    var keys=Object.keys(scores);
  
    for (var i = 0; i &lt; keys.length; i++) {
      var k = keys[i];
      var name = scores[k].name;
      var scoreGl = scores[k].globalScore;
  
      $("#scorelist").append("&lt;li class='scorelisting'&gt;"+name+": "+scoreGl.toFixed(3) +"&lt;/li&gt;");
    }
  }
  </code></pre>
  
  <p>and this is how it looks like on my website:</p>
  
  <p><a href="https://i.stack.imgur.com/47Xgf.png" rel="nofollow noreferrer">Leaderboard on website</a></p>
  
  <p>I've been looking at the .orderByChild() but I can't make it work. Here is how my data in Firebase looks like when submitted:</p>
  
  <p><a href="https://i.stack.imgur.com/ZLLLZ.png" rel="nofollow noreferrer">Screenshot of my Firebase</a></p>
  
  <p>Here's the link to my project: www.targetime.surge.sh</p>