Feature Request: Customizable Sorting (ASC/DESC) for Directories & Navigation, ideally with Per-Directory Configuration
Hello,
I would like to suggest a feature to allow customization of the sorting order for directories and navigation items. Currently, the sorting seems fixed.
It would be very helpful to be able to choose between:
Ascending (ASC) order Descending (DESC) order Ideally, it would be even better if this sorting could be configured individually for each directory. This would provide more granular control over how content is presented.
Sort order is alphabetic by default, directories first, and can be changed to "freeform".
See https://madness.dannyb.co/#controlling-sort-order
Hopefully this helps. If it is not clear or not helpful, let me know.
Thanks for your reply and the link to the documentation.
I understand the points you've made, and I have reviewed the documentation regarding controlling sort order.
However, I couldn't find a specific option to simply set the default sort order to descending (DESC). My understanding is that the default is currently ascending (ASC).
While 'freeform' sorting offers custom control, what I'm primarily looking for is a straightforward way to just reverse the default sorting to DESC without needing to define a fully custom order.
Is there an existing way to achieve this simple DESC setting for the default sort that I might have missed?
No, there is no descending sorting order. There is only the custom sorting order, or this option in the settings file:
# choose navigation sort order:
# sort_order: dirs_first # alphabetic directories then alphabetic files
# sort_order: mixed # alphabetic regardless of type
sort_order: dirs_first
Also, if you want to just "bubble up" one or more of the directories / files, you can just prefix them with the number-dot notation:
1. Getting Started.md
2. Installing.md
Another FIle.md
And Another File.md
I do not see the point of a descending order, and it is unlikely to be implemented, let alone on a per-directory basis.
If you have a convincing use case why this is needed and not covered by the existing sorting features, I am open to reconsidering.
Thanks for the detailed explanation.
The main reason I'm looking for a descending order option is because my Markdown directory and file structure is primarily organized by date (e.g., YYYY/MM/DD/file.md or YYYY-MM-DD-file.md). With this naming convention, a descending sort (DESC) would naturally place the most recent content at the top, which is very convenient for quickly accessing the latest entries.
I've taken a brief look at the code, and it seems that adding a global configuration option for descending order might be a relatively minor modification. I'm planning to try and implement this for my own use, as a simple global DESC toggle would be very beneficial for this particular use case.
Thanks again for your consideration and the discussion!
This is a valid use case. Keep the issue open, I might add it.
Looking at your implementation, I think I would rather have a separate boolean flag: reverse_sort: true (false by default). then it is fully backwards compatible, and you only need to check one condition.