Nested sorting for page resources

Hi all!

When I range through .Resources like this, the images are automatically ordered alphabetically:

{{ range $image := (.Page.Resources.ByType "image") }}

Yet, when I sort by a year param (some image have the same year param, e.g. “2020”) the secondary sorting is not alphabetically but seems arbitrary:

{{ range $image := sort (.Page.Resources.ByType "image") ".Params.year" "desc" }}
  • 2020 b
  • 2020 a
  • 2020 c

Unfortunately it does not seem seems to be possibly nest the sorting like this:

{{ range $image := sort (sort (.Page.Resources.ByType "image") ".Name") ".Params.year" "desc" }}

and .ByParam does not work with Page Resources.

Does anyone have an idea how to use nested sorting for page resouces?

Can you share a repository?

Please post a link to the public repository for your site. See:
https://discourse.gohugo.io/t/requesting-help/9132

Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.

If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.