# Sort\_by slug / path

**URL:** <https://zola.discourse.group/t/sort-by-slug-path/1349>\
**Category:** Feature requests\
**Created:** [June 4, 2022, 4:36pm UTC](https://zola.discourse.group/t/sort-by-slug-path/1349 "2022-06-04T16:36:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bemyak](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/bemyak/32/1106_2.png) [@bemyak](https://zola.discourse.group/u/bemyak)\
**Post date:** [June 4, 2022, 4:36pm UTC](https://zola.discourse.group/t/sort-by-slug-path/1349/1 "2022-06-04T16:36:28Z")

</div>

My use-case is pretty straightforward and seems quite common to me. I have a number of pages and sections that start with a number prefix e.g., `00_post.md`, `01_post.md`, etc., and I’d like to have them sorted by this prefix. They don’t have this number in a title, so sorting by `title` is not an option. The only way is to sort by weight, which requires adding it to every single page.

The default sorting (`none`) seems to sort entities in random order, which makes no sense to me.

I can add a new sorting order: `sort_by = slug` or `path`, whichever seems more reasonable to you.

Let me know what you think, so I can start working on it.

---

<div class="post-metadata">

**Author:** ![matthillco](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/matthillco/32/869_2.png) [@matthillco](https://zola.discourse.group/u/matthillco)\
**Post date:** [November 29, 2022, 8:52pm UTC](https://zola.discourse.group/t/sort-by-slug-path/1349/2 "2022-11-29T20:52:06Z")

</div>

+1 for this feature request. I’m working on a project with hundreds of files that begin with a number, and need to be processed in ascending order. At present I have to add a sequential weight into every `.md` file which is hugely inefficient. Being able to sort on filename would be a god send, and I imagine very useful for other similar use-cases.

---

<div class="post-metadata">

**Author:** ![bemyak](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/bemyak/32/1106_2.png) [@bemyak](https://zola.discourse.group/u/bemyak)\
**Post date:** [November 30, 2022, 5:24am UTC](https://zola.discourse.group/t/sort-by-slug-path/1349/3 "2022-11-30T05:24:49Z")

</div>

Hi, @matthillco ! This is already implemented and should be available in the latest Zola release

> <https://github.com/getzola/zola/pull/1926>
>
> In https://github.com/getzola/zola/pull/1917 we discussed that sorting by \`slug\`… probably makes more sense than by \`filepath\`, so here is the implementation.
> 
> \---
> 
> Sanity check:
> 
> \* \[X\] Have you checked to ensure there aren't other open \[Pull Requests\](https://github.com/getzola/zola/pulls) for the same update/change?
> \* \[X\] Are you doing the PR on the \`next\` branch?
> \* \[X\] Have you created/updated the relevant documentation page(s)?

---

<div class="post-metadata">

**Author:** ![matthillco](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/matthillco/32/869_2.png) [@matthillco](https://zola.discourse.group/u/matthillco)\
**Post date:** [November 30, 2022, 9:35am UTC](https://zola.discourse.group/t/sort-by-slug-path/1349/4 "2022-11-30T09:35:07Z")

</div>

@bemyak Oh cool, that sounds great! Looks like it’s still in the `next` branch though and not released yet. Sorting by slug in 0.16.1 generates an unknown variant error. I can’t wait to try this out in the next release, it will save me a ton of time! Thank you for proposing and working on this fix. 👍

Incidentally, will this still work if I’m using `path` overrides in my meta data? I’m working with sequential numbered files, but need to hard-code their final deployment paths to end up in different locations. Will my setup work with sorting by slug in this case?
