Support Sorting by Multiple Attributes
Hi,
I've got a list of posts. When I publish our site, we just use the day, I don't keep a full timestamp in the frontmatter, as we don't want to present it to the user.
This therefore means that when there is more than one post on a given day, the order of posts isn't fully defined, and so I get spurious changes in my commits for the HTML, which are a bit distracting when I'm making important changes to the templates etc. as I try to keep each one granular.
So far I am using a simple loop:
for page in allPages | sort(attribute="date") | reverse
What I'd like to propose is the possibility to sort a hashmap on multiple keys - so that it'll be sorted on the first, then any that have identical values for the first key, they'll be compared using the next key, etc.:
for page in allPages | sort(attribute=["date", "title"]) | reverse
This way I can use my date as the primary criterion and still have a means to stop them from jumping around in the list. Currently I can think of a few ways to work around, but if folks agree, feels like it'd be a nice feature to add. Thoughts?
Thanks
It could be added, but I wouldn't add it to v1. This filter still needs to be rewritten for v2 so it could be good candidate for improvement
Yep, for sure. Opened a specific FR as it felt more of a change to an existing feature than a hypothetical "wishlist" sort of thing, but of course add it to the next version, and I've got my workaround with group-by in the meantime.