# Nested sorting for page resources

**URL:** <https://discourse.gohugo.io/t/nested-sorting-for-page-resources/27176>\
**Category:** support\
**Created:** [July 26, 2020, 1:14pm UTC](https://discourse.gohugo.io/t/nested-sorting-for-page-resources/27176 "2020-07-26T13:14:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grob](https://avatars.discourse-cdn.com/v4/letter/g/f14d63/32.png) [@Grob](https://discourse.gohugo.io/u/Grob)\
**Post date:** [July 26, 2020, 1:14pm UTC](https://discourse.gohugo.io/t/nested-sorting-for-page-resources/27176/1 "2020-07-26T13:14:10Z")

</div>

Hi all!

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

```auto
{{ 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:

```auto
{{ 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:

```auto
{{ 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?

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [July 26, 2020, 1:56pm UTC](https://discourse.gohugo.io/t/nested-sorting-for-page-resources/27176/2 "2020-07-26T13:56:07Z")

</div>

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](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.
