Necesito ayuda para ordenar unos valores al mostrarse

  • Autor Autor Griffith
  • Fecha de inicio Fecha de inicio
Griffith

Griffith

Épsilon
Verificado por Whatsapp
HTML:
 
Última edición:
HTML:
<!DOCTYPE html>
<html lang="es">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <title>Document</title>
</head>
<body>
    <div class="principal">
        <script>
            var pilotos = new Array();
            pilotos = [
                [
                    "Lando Norris", 4, 60
                ],
                [
                    "Sebastian Vettel", 5, 10
                ],
                [
                    "Carlos Sainz", 55, 50
                ],
                [
                    "Lewis Hamilton", 44, 15
                ],
                [
                    "Kimi Rikkonen", 7, 37
                ],
            ];

            function order(a, b)
            {
                if (a[2] < b[2]) return -1;
                if (a[2] > b[2]) return 1;
                return 0;
            }

            pilotos.sort(order);

            document.write('<div class="contenedor">');

            for (i = 0; i < pilotos.length; i++) {

                document.write('<div class="caja">');
                document.write('<div class="detallito">', '<div class="name"><div class="namecolor"><h3>' + pilotos[i][0] + '</h3></div><h4>');
                document.write('<div class="numbcolor">', 'Número:  ' + pilotos[i][1] + '</div></h4></div>');
                document.write('<div class="marks"><div class="time"><h3>', 'Tiempo:  ' + pilotos[i][2] + ' minutos', '</h3></div></div></div>');
                document.write('</div>');
            }
        </script>
    </div>
</body>
</html>
 
soy desarrollador wed certificado comentame
 
Atrás
Arriba