Alphabetical Taxonomy list?

I am trying to list taxonomy items alphabetically. I pulled the partial from the taxonomy list plugin (user/plugins/taxonomylist/templates/taxonomylist.html.twig) and am using it like this:

{% include ‘partials/taxonomylist.html.twig’ with {‘taxono my’:‘location’} %}

But I’d like to have things ordered alphabetically instead of by # of uses. How can I accomplish this?

Thanks!

if you look in the taxonomylist.html.twig partial (in the plugin) you will see that really its just an associative array. You should be able to use a Twig Sort filter to sort this array alphabetically.

Thanks. Doing {% for tax,value in taxlist[taxonomy]|sort %}
does give me a different order, but not alphabetical. Not sure what that order is — maybe just the order in which the tax list is being built, which seems kind of random. Any other ideas?

Yah, it’s the keys you need to sort. I thought Twig had this built in, but I had to create a new ksort filter rather than just the sort you tried:

https://github.com/getgrav/grav/commit/08fc3918a72cda2fd725dc84567d8bceb49abf08

Awesome… {% for tax,value in taxlist[taxonomy]|ksort %} now works like a charm. Thanks.