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
252 stars 19 forks source link

Supply additional sort rules when initial criteria don't fully specify order #85

Closed edemko closed 9 months ago

edemko commented 11 months ago

I have tried everything I can find/think of to get this to work, but in lieu of that awful title, lemme give my concrete example:

I've got a folder of journal entries labelled with human-redabnle rough date-times (oh, and some of the times are missing smh):

I'd like to sort these descending by date, but ascending by time/sequence number. I've added date and time metadata fields (perhaps someday I'll be able to do this from the filename but for now I'm going for easy mode first). Sorting by only one or the other does give the expected results, but when I try to combine them, everything goes wonky.

    target-folder: Journal
    > a-z by-metadata: date, < a-z by-metadata: time

gives

which looks like descending time, then descending date within those groups. Oddly, > a-z by-metadata: time, < a-z by-metadata: date does not change the order. To be fair, I can't really tell what comma is supposed to be doing anyway.

    target-folder: Journal
    > a-z by-metadata: date
     < a-z by-metadata: time

gives

I did try /! operators at one point, but it didn't work, and the docs suggest that's not right either.

At this point, anything is helpful! I'm not even convinced this capability exists (yet!).

SebastianMC commented 10 months ago

Hi @edemko

what you describe is clearly a multi-level sorting, two-levels in your example. This is a standard capability of databases and search engines. At the same time it is not implemented in the custom-sort plugin.

I've created a new issue (#86) to assess the complexity of implementation of this new feature. I'm looking in the direction of your example:

  target-folder: Journal
  > a-z by-metadata: date, < a-z by-metadata: time

Until the feature is available, there is no simple workaround to combine sorting by two metadata fields.

In #86 I also mentioned some simpler less generic options of implementation. The one of numeric by-metadata: -date, time seems tempting and trivial to implement, isolated and with no big impact. I need to sleep on this idea.

SebastianMC commented 9 months ago

Status update: the multi-level sorting feature has been implemented under #89 - more details in this comment

It will be included in the coming release

SebastianMC commented 9 months ago

The multi-level sorting feature is available in 1.9.0 release of the plugin. More detailed documentation will follow.

For the specific example described in this thread, the final syntax is:

---
  target-folder: Journal
  > a-z by-metadata: date, < a-z by-metadata: time
---

In other words:

Thank you @edemko - your request was the trigger to build-in the explicit support for multi-level sorting feature