Photo of Miqueas Nieves

0

Sort problem

This lava is not sorting the FirstName. It sorts the last name very well. Also it does not include all the names in the dataview. How do I fix this? I would like it to sort the last name and then the first name. Why is it not including all the names in the dataview? I thank you in advance for you help. God bless



{% person where:'Position _! "" ' sort:'LastName, FirstName desc' %}

    {% for person in personItems %}

       {% assign CurrLName = person.LastName %}

              {% if CurrLName != empty %}

{{ person.LastName }}, {{ person.FirstName }}, {{ person | PhoneNumber:'Mobile' | Default:'No tiene Cell' }}, {{ person | Address:'Home' | Default:'-- No tiene direccion --' }}
             {% endif %}

    {% endfor %}

{% endperson %}

  • Photo of Nate Barber

    0

    Lava is simply the "Liquid coding language" implemented within Rock, so I tried searching "liquid code sort multiple" in the googles. What I found is that sort can only sort one thing at a time, which means that you will need to first sort by first name, then sort the results by last name.

    There's a liquid example here:

    https://stackoverflow.com/questions/25652231/shopify-sort-array-using-liquid-script-with-2-criteria

    The sort method can also only sort ascending. If you want to display things in reverse order you will need to add the 'reversed' attribute to your for loop statement.

    For example, the following will sort children by age (ascending) then loop through the sorted results reversed to display their names and ages in descending age order:

    {% assign children = Row | Children | Sort:’Age’ %}{% for child in children reversed %}

    More on for loops in lava:

    https://www.rockrms.com/page/465