# Indeterminate behaviour using range and reverse range in same partial

**URL:** <https://discourse.gohugo.io/t/indeterminate-behaviour-using-range-and-reverse-range-in-same-partial/14643>\
**Category:** support\
**Created:** [October 9, 2018, 6:17pm UTC](https://discourse.gohugo.io/t/indeterminate-behaviour-using-range-and-reverse-range-in-same-partial/14643 "2018-10-09T18:17:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![beno](https://avatars.discourse-cdn.com/v4/letter/b/85e7bf/32.png) [@beno](https://discourse.gohugo.io/u/beno)\
**Post date:** [October 9, 2018, 6:17pm UTC](https://discourse.gohugo.io/t/indeterminate-behaviour-using-range-and-reverse-range-in-same-partial/14643/1 "2018-10-09T18:17:35Z")

</div>

I can reproduce this issue quite simply using the “Quick Start” project.

Steps to reproduce:

- Follow the steps to get a working Hugo site outlined in the Quick Start
- Create a number of pages and add them to the main menu by adding `menu: ["main"]` to the front matter
- Edit the `themes/ananke/layouts/partials/site-navigation.html` to add the following code directly after the matching block that renders the menu in a forwards direction. (Note the `.Reverse` added to the menu array)

```auto
        <ul class="pl0 mr3">
          {{ range .Site.Menus.main.Reverse }}
          <li class="list f5 f4-ns fw4 dib pr3">
            <a class="hover-white no-underline white-90" href="{{ .URL }}" title="{{ .Name }} page">
              {{ .Name }}
            </a>
          </li>
          {{ end }}
        </ul>

```

EXPECTED: the list of pages followed by the list of pages in reverse displayed consistenty on each of the pages as you click through them.

ACTUAL: Indeterminate ordering of the ranges as you click through the pages.

My guess is that the pages are being rendered in parallel and there is a range cursor that’s being trampled by different threads… or I’m missing something obvious and doing something wrong.

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [October 10, 2018, 2:07am UTC](https://discourse.gohugo.io/t/indeterminate-behaviour-using-range-and-reverse-range-in-same-partial/14643/2 "2018-10-10T02:07:47Z")

</div>

I’ll test it out if you wrap your test project in a repo and share it. 🙂

---

<div class="post-metadata">

**Author:** ![moorereason](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/moorereason/32/592_2.png) [@moorereason](https://discourse.gohugo.io/u/moorereason)\
**Post date:** [October 12, 2018, 7:01pm UTC](https://discourse.gohugo.io/t/indeterminate-behaviour-using-range-and-reverse-range-in-same-partial/14643/3 "2018-10-12T19:01:19Z")

</div>

The results prior to `Reverse` are not deterministic, and `Reverse` doesn’t cause a sort to occur [[1](https://github.com/gohugoio/hugo/blob/ae5a45be6f0ee4d5c52b38fd28b22b55d9cd7b2d/hugolib/menu.go#L205-L212)]. You should sort prior to reversing. Try this:

```auto
{{ range .Site.Menus.main.Sort.Reverse }}

```

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [August 21, 2020, 12:32am UTC](https://discourse.gohugo.io/t/indeterminate-behaviour-using-range-and-reverse-range-in-same-partial/14643/4 "2020-08-21T00:32:20Z")

</div>

A post was split to a new topic: [Sorting Menu by weight and reversed](https://discourse.gohugo.io/t/sorting-menu-by-weight-and-reversed/27710)

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [August 21, 2020, 12:32am UTC](https://discourse.gohugo.io/t/indeterminate-behaviour-using-range-and-reverse-range-in-same-partial/14643/5 "2020-08-21T00:32:26Z")

</div>



---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [August 21, 2020, 12:32am UTC](https://discourse.gohugo.io/t/indeterminate-behaviour-using-range-and-reverse-range-in-same-partial/14643/6 "2020-08-21T00:32:32Z")

</div>


