obsidian-custom-sort icon indicating copy to clipboard operation
obsidian-custom-sort copied to clipboard

Advanced sorting by metadata values ordered with custom 'lookup list' idea (a non alphabetical, non numerical, arbitrary list of labels)

Open SebastianMC opened this issue 11 months ago • 5 comments

Parking the idea posted by @Chapien here in discussions.

[...] is it possible to manually sort by metadata, in an explicit order? I have a reading list, with a property called 'status' that can have three values: reading, unread, complete. I want to manually sort it so that those with the reading status are on top, then unread, then complete. However, I can only see how to sort with implicit (ie, by alphabetical order) instructions. Is there any way I can list a pre-defined order of priority? Ie hard define the order as "reading, unread, complete" based on the metadata value.

SebastianMC avatar Jan 31 '25 17:01 SebastianMC

Oh, then I'm guessing it's not yet possible. Glad it was a good idea though!! Thank you.

Chapien avatar Jan 31 '25 23:01 Chapien

@Chapien yup, not supported for now, as stated below your original question in discussions.

Yet, after sleeping on the idea it turned out that a simple implementation is at hand, a low hanging fruit. I should have time to do it in two weeks from now, and the concept boils down to grouping items by the value of specified metadata (for now grouping can be driven by presence of specified metadata with any value).

---
sorting-spec: |
  with-metadata: status value-matching(reading)
    > modified 
  with-metadata: status value-matching(unread)
    > created
  with-metadata: status value-matching(complete)
    < a-z
---

SebastianMC avatar Feb 01 '25 22:02 SebastianMC

This looks great, looking forward to the update.

Chapien avatar Feb 02 '25 15:02 Chapien

I came across this same sort need, but I haven't been able to get the syntax to work. Using the OP's objective, would you be willing to provide an example of what that final sortspec would look like?

jodyblau avatar Aug 27 '25 03:08 jodyblau

Hi @jodyblau,

the feature has not been released yet, a work in progress. The relevant PR is #196. Need to implement handling of additional scenarios and create unit tests to cover the new feature.

SebastianMC avatar Aug 27 '25 09:08 SebastianMC