Skip to content

Instantly share code, notes, and snippets.

@bartwttewaall
Last active January 14, 2022 09:03
Show Gist options
  • Save bartwttewaall/1498ab08bebdf450db0a4d8d35a1570d to your computer and use it in GitHub Desktop.
Save bartwttewaall/1498ab08bebdf450db0a4d8d35a1570d to your computer and use it in GitHub Desktop.
Sort on multiple properties by priority and ASC/DESC
{% for language in languages|sort((a, b) => [b.selected, a.title] <=> [a.selected, b.title]) %}
<div class="{{ language.selected ? 'selected' }}">{{ language.title }}</div>
{% endfor %}
{# The order of properties determines priority #}
{# The order of a or b determines ASC or DESC sorting #}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment