1
I can’t print the records in descending order. I looked on several websites for tips that could help me, but when I adapt to my code, nothing works!
My question is this::
I’m creating a game on Intel XDK using Firebase as a database and Javascript to handle it, but I can’t display the logs on rising order and neither decreasing, which is what I want. Equal to a Ranking.
I have the following code:
<html>
<head>
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale= 1.0, maximum-scale= 1.0, user-scalable=no />
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <script src="https://cdn.firebase.com/js/client/1.0.17/firebase.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.css></script>
</head>
<body>
<table>
    <thead>
        <th>NOME</th>
        <th>TEMPO</th>
        <th>ACERTOS</th>
        <th>ERROS</th>
    </thead>
    <tbody id="resultado">
    </tbody>
</table>
<script>
    $(document).ready(function(){
        var APP = new Firebase("https://testestroop-c52df.firebaseio.com/");
        APP.ref().child('jogada').on('child_added', function(snap){
            var jogada = snap.val();
            var tr = document.createElement('tr');
            var td1 = document.createElement('td');
            var td2 = document.createElement('td');
            var td3 = document.createElement('td');
            var td4 = document.createElement('td');
            td1.appendChild(document.createTextNode(jogada.nomeJogador));
            tr.appendChild(td1);
            td2.appendChild(document.createTextNode(jogada.tempo));
            tr.appendChild(td2);
            td3.appendChild(document.createTextNome(jogada.acertos));
            tr.appendChild(td3);
            td4.appendChild(document.createTextNode(jogada.erros));
            tr.appendChild(td4);
            resultado.appendChild(tr);
        }
    });
</script>
</body>
</html>
And in this image below is the structure of the database in Firebase:

I really appreciate your help.
Hi Chun, my computer was crashing a lot so I had to type all the code through the phone, I just saw that I forgot to put commas, semicolons, those things. But the code is working perfectly. My question is as follows: How to display the Firebase records for hits in descending order. As a ranking, whoever has the most hits appears at the top of the table
– Priscila Bispo