Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort notes in dd-Mmm-yyyy format #151

Closed
DvValk opened this issue Jun 26, 2024 · 6 comments · Fixed by #152
Closed

Sort notes in dd-Mmm-yyyy format #151

DvValk opened this issue Jun 26, 2024 · 6 comments · Fixed by #152
Assignees
Labels
enhancement New feature or request

Comments

@DvValk
Copy link

DvValk commented Jun 26, 2024

Personally I think the date format: dd-Mmm-yyyy is superior to all others as there is no confusion possible between different parts of the world. However, it is horrible while trying to sort. Would it be hard for you to implement this into your nice plugin? Or maybe it is already possible, but I just don't know how to create the correct yaml file?

e.g.:
20-Nov-2024
05-May-2024
26-Dec-2023
13-Oct-2020

Thanks!

@SebastianMC SebastianMC added the enhancement New feature or request label Jun 27, 2024
@SebastianMC
Copy link
Owner

SebastianMC commented Jun 27, 2024

Hi @DvValk

thanks for reporting this feature request!
This sorting method is not supported yet. It doesn't fall into category of numerical or alphabetical, and cannot be easily translated to / mapped to alphabetical or numerical, because of month names - requires some arbitrary ordering.

At the same time implementing this is trivial, thus adding it to the list of enhancements (the first one to be done).

@DvValk
Copy link
Author

DvValk commented Jun 27, 2024

Awesome, thanks for putting it on your to-do list! Looking forward to it :)

@SebastianMC SebastianMC self-assigned this Jul 8, 2024
@SebastianMC SebastianMC linked a pull request Jul 9, 2024 that will close this issue
@SebastianMC SebastianMC reopened this Jul 10, 2024
@SebastianMC
Copy link
Owner

SebastianMC commented Jul 10, 2024

Implementation completed, a robust example from tests:

2024-07-10_12-05-09

The exact sorting spec above:

---
sorting-spec: |
  /+ \[dd-Mmm-yyyy]
  /+ ... \[dd-Mmm-yyyy]
  /+ \[dd-Mmm-yyyy] ...
    < a-z
---

The newly introduced syntax \[dd-Mmm-yyyy] can be used to match note titles (or part of titles) containing dates in that specific format, all case sensitive (the syntax and the months in note titles).
The above example takes advantage of the /+ to combine multiple criteria. It can be read as:

  • /+ \[dd-Mmm-yyyy] - if a note title comprises only date in that format, OR
  • /+ ... \[dd-Mmm-yyyy] if a note title ends with date in that format, OR
  • /+ \[dd-Mmm-yyyy] ... if a note title starts with date in that format, THEN
  • < a-z group the notes and sort by that date, the oldest date first

A simpler example for a folder Attachments containing the notes / files or subfolders with names comprising only the date, to be sorted with the newest pushed to the top, would look like:

---
sorting-spec: |
  target-folder: Attachments
  \[dd-Mmm-yyyy]
    > a-z
---

This feature available in the 2.1.12 release of the plugin

@DvValk
Copy link
Author

DvValk commented Aug 12, 2024

Many thanks @SebastianMC, it works like a charm and makes my project folders very clear!

@andre-000
Copy link

@SebastianMC anyway to use a similar sorting method but for the Mmm-dd-yyyy format (e.g. Jan-01-2025)?

@SebastianMC
Copy link
Owner

Hi @andre-000

anyway to use a similar sorting method but for the Mmm-dd-yyyy format (e.g. Jan-01-2025)?

this was a low-hanging-fruit, a new 2.1.5 has been exposed with this feature.

The relevant pattern to use is \[Mmm-dd-yyyy]

An example sorting spec to capture files and folders with a date suffix in that format:

---
sorting-spec: |
  target-folder: Attachments
  ... \[Mmm-dd-yyyy]
    > a-z
---

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants