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

Add sort order parameter #821

Open
micahellison opened this issue Jan 25, 2020 · 8 comments
Open

Add sort order parameter #821

micahellison opened this issue Jan 25, 2020 · 8 comments
Labels
enhancement New feature or request 📌 This can't go stale
Milestone

Comments

@micahellison
Copy link
Member

micahellison commented Jan 25, 2020

Currently, jrnl only outputs in ascending order. Adding a sort feature would allow for lots more flexibility in recipes and perhaps the export functionality as well. For instance, being able to get the date of the earliest (rather than latest) entry that matches a particular search would help with a recipe for #818.

There are lots of different ways this go, however, and I'd love to here anyone's thoughts on the best approach:

  • it could only sort the output
  • it could only affect the -n argument behavior
  • it could affect the output and -n at the same time
  • there could be separate arguments for display order vs. search order
  • there could be an argument for display order, then an additional argument that's like -n except it's always working in ascending

Looks like part of this issue was brought up in #396, but it staled out. I think whatever the consensus is, we'll want to carefully measure its impact on the rest of the functionality, since this affects everything from display to editing to exporting to future recipes.

@stale
Copy link

stale bot commented Apr 1, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Inactive issue: will be closed soon if no activity label Apr 1, 2020
@wren wren added the 📌 This can't go stale label Apr 4, 2020
@stale stale bot removed the stale Inactive issue: will be closed soon if no activity label Apr 4, 2020
@damufo
Copy link

damufo commented Jun 23, 2020

It would also add the option/parameter to store in descending order.

journals:
default: ~/journal.txt
work:
journal: ~/work.txt
encrypt: true
store_reverse: true
food: ~/my_recipes.txt

Example work.txt:
[2020-05-12 09:00] Test 3.
Content test3.

[2020-05-11 09:00] Test 2.
Content test2.

[2020-05-10 09:00] Test 1.
Content test1.

@wren
Copy link
Member

wren commented Aug 6, 2020

The more I've been thinking about this, the more it seems like a format parameter. And since search happens first, then all search results are handed to a formatter (which can reverse the order while displaying), then this wouldn't have any effect on -n behavior.

Also, @damufo, sorry but this wouldn't have any effect on how a journal is stored. We currently don't have any plugins other than encryption to change a journal's storage in a file (although we may revisit that in the future).

@gustiando
Copy link
Contributor

gustiando commented Jan 2, 2021

Some sort of sorting here would be beneficial for my use case. I want to publish my public journal online where readers would load the page and get the most recent posts on top. Curious if there are any further plans to resolve this issue.

@wren
Copy link
Member

wren commented Jan 2, 2021

@gumatias It's pinned in our backlog, so we will get to it eventually. But it's not currently at the top of our priority list.

We always happily accept PRs for pinned issues, though, if anyone wants to get it implemented sooner.

@wren wren added this to the Backlog milestone Nov 13, 2021
@xeruf
Copy link
Contributor

xeruf commented Sep 27, 2022

I would like to apply this on the file storage, can't we add that as a parameter in the config?

@micahellison
Copy link
Member Author

I would like to apply this on the file storage, can't we add that as a parameter in the config?

Thanks @xeruf for the idea -- I'm spinning it off to a separate issue (#1609) since storage is such a different concern from presentation.

@micahellison
Copy link
Member Author

Whatever this feature ends up looking like, it should affect sorting in both the editor and the console search results.

See #1671 for a feature request on sorting by tags.

This also brings up the question of using multiple sort calls at once. It makes me think there should probably be -sort (or --sort?) argument that takes a sort type then 1 or more sort criteria.

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

No branches or pull requests

5 participants