Ordering tags chronologically & by postcount

Hello all,

I’ve been trying to built a navigation menu for my (photo)blog (repo here). I have the correct (working) tags, but I can’t seem to figure out how to order and limit them like I want.

Right now, I have a partial that reads as follows:

<nav class="nav">
    <ul class="series">
<!-- Range over series -->
        {{ range $name, $taxonomy := .Site.Taxonomies.series }}
        <li><a href="/series/{{ $name | urlize }}">{{ $name }}</a></li>
        {{ end }}

    <ul class="tags">
<!-- Range over top 5 tags -->
        {{ range $name, $taxonomy := .Site.Taxonomies.tags }}
        <li><a href="/tags/{{ $name | urlize }}">{{ $name }}</a></li>
        {{ end }}

How would I go about ordering these? Sorting the series chronologically (the newest series first) and the tags by (the five) most used ones?

There is the sort function to start with:

You can also access Taxonomies already sorted by name or count (ASC/DESC)

No guarantees and untested, but I would start with these

{{ range $index, $var := (sort .Site.Taxonomies.series "Count") }}
{{ range $index, $var := (first 5 (sort .Site.Taxonomies.series "Count")) }}