SebastianMC / obsidian-custom-sort

Take full control over the order and sorting of folders and notes in File Explorer in Obsidian
GNU General Public License v3.0
302 stars 23 forks source link

Custom sorting based on YAML frontmatter creation date? #177

Open bloominburges opened 1 week ago

bloominburges commented 1 week ago

How do i use your add in to sort the files in a folder by the note’s “created” property in my YAML frontmatter? I want it to do it off of this frontmatter property, NOT the file property as the source of truth like some other admins do.

Thanks

SebastianMC commented 1 week ago

Hi @bloominburges,

the base idea of sorting specification which you described is:

---
sorting-spec: |
  > a-z by-metadata: created
---

The above simple sorting spec works under the following assumptions:

bloominburges commented 4 days ago

Got it… thanks. What about if i want reverse? I tried “> z-a by-metadata: created”, and it didn’t work

SebastianMC commented 3 days ago

The syntax of sorting order specification in this particular example comprises three elements and two of them are relevant to your question:

  1. The direction of the order - ascending or descending. In this case the token is >
    • > stands for descending order, larger values go first. You can use more verbose syntax for it: order-desc: as an equivalent for readability
    • < can be used for the ascending order, smaller values go first. Verbose equivalent syntax is order-asc:

To change the order direction to reverse you need to switch > to <, and vice versa

  1. The actual sorting order - in this case the token is a-z which represents the alphabetical sorting. It has no reverse equivalent and the direction specification (1) is used to switch between alphabetical and reverse alphabetical.

The spec to use is then: