Score:0

Trying to sort rows by a column in views twig template

id flag

I'm trying to sort the rows of a view in the table template but can't figure out how to sort by a particular column. I can only get it to sort by the first column. I'm trying to sort a views global conditional field so I can't use views query alter. Here's the code that sorts by the first column. I've tried various arrow functions without any luck.((a, b) => a.row.column <=> b.row.column).

<tbody>
  {% for row in rows|sort %}
    <tr{{ row.attributes }}>
      {% for key, column in row.columns %}
        {% if column.default_classes %}
id flag
https://stackoverflow.com/questions/25194470/twig-sort-array-of-objects-by-field
davidp avatar
id flag
Thanks @cilefen I think I asked the question badly. How do I access the column numbers as indicated in the header of the template file? * - rows: Table row items. Rows are keyed by row number. * - attributes: HTML classes to apply to each row. * - columns: Row column items. Columns are keyed by column number.
id flag
I think this is essentially a Twig programming question. It’s hard to formulate an answer not really knowing what are the contents of the data. Output of the `dump` function would help this Question out.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.