Sort taxonomylist

Hey everyone,
I need to arrange my taxonomylist alphabetically. I found older forumposts mentioning the ksort function, but it seems not to work anymore. Also found something about the sort_by_key function and tried that, but I think I’m not doing it correctly. Could you help out? Here is my code:

{% set taxlist = taxonomylist.get() %}
{% if taxlist %}
  {% set category = grav.uri.params("category", true) %}
  {# for tax,value in taxlist['category']|sort_by_key('tax') #}
  {% for tax,value in taxlist['category']|ksort %}
    {% set current_page = (tax == category) ? 'active' : '' %}
    <li class="">
      <a href="{{ page.url }}/category{{ config.system.param_sep }},{{ tax|e('url') }}">{{ tax|capitalize }}</a>
    </li>
  {% endfor %}
{% endif %}

Thanks in advance!

Hey, is there anyone who knows how to deal with this issue? Thanks a lot in advance :slight_smile:

Your sort command is commented out. Does it work as expected when active?

@Bob, I added both the options I tried. Both did not work :unamused:

I’m using a sort of this form:

{% for tag in page.taxonomy.tag|sort %}