# Order structures in data folder

**URL:** <https://discourse.gohugo.io/t/order-structures-in-data-folder/5647>\
**Category:** support\
**Created:** [March 1, 2017, 5:08pm UTC](https://discourse.gohugo.io/t/order-structures-in-data-folder/5647 "2017-03-01T17:08:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SamPotasz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/sampotasz/32/2172_2.png) [@SamPotasz](https://discourse.gohugo.io/u/SamPotasz)\
**Post date:** [March 1, 2017, 5:08pm UTC](https://discourse.gohugo.io/t/order-structures-in-data-folder/5647/1 "2017-03-01T17:08:26Z")

</div>

Hi all,

I’m trying to display some content that I’ve got in a TOML file inside my data folder **in a specific order**. I’m following the basic example [here](https://gohugo.io/extras/datafiles/).

My `issues.toml` file looks like this:

```
[Start]
title = "The Start Issue"
published = "1979-05-27"

[Imperfection]
title = "The Imperfection Issue"
published = "1982-05-27"

[Friendship]
title = "The Friendship Issue"
published = "1980-05-27"

```

And then I’m displaying them in a layout file with

```
<ul>
  {{ range $.Site.Data.issues }}
     <li>{{ .title }}</li>
  {{ end }}
</ul>

```

It shows up just fine, but I really want to order my data by published date. **Is this possible with an extra argument to the range function?** Currently, I can’t quite figure how the data is ordered by default.

Thanks so much,  
Sam

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 1, 2017, 5:15pm UTC](https://discourse.gohugo.io/t/order-structures-in-data-folder/5647/2 "2017-03-01T17:15:58Z")

</div>

See [https://gohugo.io/templates/functions#sort](https://gohugo.io/templates/functions#sort)

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 1, 2017, 5:18pm UTC](https://discourse.gohugo.io/t/order-structures-in-data-folder/5647/3 "2017-03-01T17:18:44Z")

</div>

But note that for the date sorting to be something other than string sorting, you should consider making your dates into “proper dates”.

As an example, this weird construction from the Hugo docs would not work with strings:

> <https://github.com/gohugoio/hugo/blob/e9921ae4b267ea7200aa67e6397f757b22a8261f/docs/layouts/index.html>

---

<div class="post-metadata">

**Author:** ![bep](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/bep/32/3332_2.png) [@bep](https://discourse.gohugo.io/u/bep)\
**Post date:** [March 1, 2017, 5:21pm UTC](https://discourse.gohugo.io/t/order-structures-in-data-folder/5647/4 "2017-03-01T17:21:38Z")

</div>

Another “also”: The data structure you got in the above, I think, will become a Go map, which is not ordered. (or: the order is undefined).

Look at

> <https://github.com/gohugoio/hugo/blob/master/docs/data/references.toml>

---

<div class="post-metadata">

**Author:** ![SamPotasz](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/sampotasz/32/2172_2.png) [@SamPotasz](https://discourse.gohugo.io/u/SamPotasz)\
**Post date:** [March 1, 2017, 5:27pm UTC](https://discourse.gohugo.io/t/order-structures-in-data-folder/5647/5 "2017-03-01T17:27:20Z")

</div>

Thanks, Bep! Working like a charm 🙂
