I’m trying to sort .Resources
by .Params.group
but it gives me an incorrect sorting order (or at least when the groups are strings), if I sort by a param made of integers, e.g. .Params.weight
, or if I change .Params.group
to integers rather than strings, then it gives me a correct sorting order.
Any ideas why my strings aren’t getting sorted right?
Sorting Template Code
{{ range sort .Resources "Params.group" }}
{{ if isset .Params "group" }}
<li>{{ .Title }} - {{ .Params.group }}</li>
{{ end }}
{{ end }}
Results (ee should be below dd):
img0 - aa
img1 - bb
img2 - cc
img4 - ee
img3 - dd
Front-Matter
---
title: "Images"
draft: false
resources:
- params:
weight: 0
group: "aa"
src: ty1O7bs.jpg
title: img0
- params:
weight: 1
group: "bb"
src: 32csSRD.jpg
title: img1
- params:
weight: 2
group: "cc"
src: 0EVDFRa.jpg
title: img2
- params:
weight: 3
group: "dd"
src: 2GaiYCZ.png
title: img3
- params:
weight: 4
group: "ee"
src: Z5HzEpr.jpg
title: img4
---