Per the sort filter you can specify an attribute. Dicts are just objects. As `sort` is applied it's inherently going over the list, as any sorting algorithm must, and the attribute will be applied to the current element (in this case a dict object). So, supply the `order` as the attribute to sort by.... Similarly, just flip the order per the other argument(s) available.
{% set reverseOrder = array|sort(True, False, 'order') %}
Easy. The hard part is how are you determining order if there are duplciates as in your listing? That's rather contradictory to what the attribute is named and isn't well-defined ;).
Per the sort filter you can specify an attribute. Dicts are just objects. As `sort` is applied it's inherently going over the list, as any sorting algorithm must, and the attribute will be applied to the current element (in this case a dict object). So, supply the `order` as the attribute to sort by.... Similarly, just flip the order per the other argument(s) available.
{% set reverseOrder = array|sort(True, False, 'order') %}
Easy. The hard part is how are you determining order if there are duplciates as in your listing? That's rather contradictory to what the attribute is named and isn't well-defined ;).
Thanks. Will try this soon. Yep, just realized that the attribute is badly named, was only using it for an example for this post. In the real scenario, we're using larger objects and going by a relevance score to sort them.