lundi 22 mars 2021

How to sort loop based on response value from array

So below is a small structure how I loop items, I want to sort them in my loop from by amount of members to smallest, instead of it being randomly displayed? How should I approach this? Also, if loop contains only 2 elements, how can I set display div to none?

    <% for item in @items %>

<%= item.name %>
<%= item.members %>

<% end %>

Aucun commentaire:

Enregistrer un commentaire