How to Sort Sections

The structure of my website is like this

├── funny-cats
│   └── kittens
│    |   └──
│   └──katten
├── funny-dogs
│   └── dogs
│    |   └──
│   └──honden

I want to sort the subsections in every Home sections. The version I list below only list the subsections but not also sort them. Anybody has similar requirement before? Thanks.

{{ $sectionname := .Title}}
{{ range .Sections }}
<h5>{{ .Title }}</h5>
{{ range first $.Site.Params.lenPagesInSectionList .Pages }}
<a href="{{.RelPermalink}}">{{.Title}}</a>
{{ end }}

{{ if gt (len .Pages) $.Site.Params.lenPagesInSectionList }}
<a href="/">Read More <span class="glyphicon glyphicon-share-alt"></span></a>
{{ end }}

How should I add sorting in {{ range .Sections }}?

{{ range .Sections.ByTitle }}

Hello bep,
Thanks. Do you know how I could assign the weight of sections and then sort them by the weight?

You need to add content files with front matter and weight to the sections (i.e. the “” type).

You are right. After assigning weight, you even don’t need use {{range .Sections.ByWeight}} becauseju {{ range .Sections }} listed the sections in the order of the weight.