Is this Nunjucks issue or the expected behavior? Is there a way to avoid sorting by integers?
A practical workaround: Values for year have to be strings here, for example 2023- (with trailing hyphen).
{% for year, posts in posts | groupby("year") %}
<h2>{{ year | replace("-", "") }}</h2>
{% for post in posts %}
<article>{{ post.title }}</article>
{% endfor %}
{% endfor %}
Hi all,
if you take this example from the Nunjucks website …
… the order of the array is respected:
green
comesbefore
blue
:Output
But if you use integers (or even quoted integers) …
… the output is sorted numerically:
Output
Expected output
Is this Nunjucks issue or the expected behavior? Is there a way to avoid sorting by integers?
A practical workaround: Values for
year
have to be strings here, for example2023-
(with trailing hyphen).Thank you.