Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

209
Vistas
How can I control where an item is placed in a dynamically rendered EJS list?

I have an <ol> in EJS that consists of info obtained from objects in a database. As I make new objects, the list gets a new <li> with their information. These objects all have a date as their first field.

Is it possible to have the <ol> sort itself chronologically based on this date field? i.e., nearest date is '1' in the list, but if an object with an earlier date is added it will become '1' and the previous near date becomes '2'. The date is also contained in its own <span> within the list.

Here's what my EJS is looking like for now:

    <ol class="shows">
    <% for(let i=0; i < info.length; i++) {%>
        <li class="show">
            <span class="bold"><%= info[i].date %></span><span>  </span><span><%= info[i].bands %></span><span> - </span><span><%= info[i].venue %></span><span> - </span><span><%= info[i].ticketPrice %></span><span> - </span><span><%= info[i].startTime %></span><span> - </span><span><a href="<%= info[i].ticketLink %>">♣</a></span>
        </li>
    <% } %>
    </ol>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Simply sort your array...

info.sort((a,b)=> b-a)
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda