Contar Repetidos y Ordenar

  • Autor Autor vueloenoferta
  • Fecha de inicio Fecha de inicio
V

vueloenoferta

Delta
Hola, que tal, me andoi rompiendo un poco la cabeza, necesito contar numero de repetidos y ordenarlo de mayor a menor

Insertar CODE, HTML o PHP:
<table class="table table-bordered table-striped">

    <thead>

      <tr>

        <th>Ip</th>

        <th>Pais</th>

        <th>Dispositivo</th>

                <th>Referer</th>

        <th>Fecha</th>

        <th>Hora</th>

      </tr>

    </thead>

    <tbody id="myTable">

        

<tr>
<td>177.245.195.76</td>
<td>Mexico</td>
<td>escritorio</td>
<td>url2.html</td>
<td>15-05-2020</td>
<td>00:00:21</td>
</tr>
<tr>
<td>181.199.47.194</td>
<td>Ecuador</td>
<td>mobil</td>
<td>url1.html</td>
<td>15-05-2020</td>
<td>00:00:38</td>
</tr>
<tr>
<td>177.247.179.154</td>
<td>Mexico</td>
<td>mobil</td>
<td>url1.html</td>
<td>15-05-2020</td>
<td>00:00:41</td>
</tr>
<tr>
<td>177.245.195.76</td>
<td>Mexico</td>
<td>escritorio</td>
<td>url3.html</td>
<td>15-05-2020</td>
<td>00:00:56</td>
</tr>
      

    </tbody>

  </table>

          <div id="tp2"> Url mas Vista.</div>


En javascritp tengo esto que me ayuda a contar, pero no ordena de mayor a menor, si alguien me ilumina lo agradecere
Aqui el codigo en funcionamiento https://codepen.io/preguntaya/pen/XWmPLyy

Codido JS
Insertar CODE, HTML o PHP:
var nFilas= 4;
var i;
var urlpe;
var urlx = [];
for (i = 0; i < nFilas; i++) {
    urlpe = document.getElementById("myTable").rows[i].cells[3].innerHTML;
    urlx.push(urlpe);
}

var repetidosurl = {};
urlx.forEach(function(numerourl){
  repetidosurl[numerourl] = (repetidosurl[numerourl] || 0) + 1;
});

document.getElementById("tp2").innerHTML = JSON.stringify(repetidosurl);
 
Atrás
Arriba