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

Reverse sort order? #143

Closed
cgoetzke opened this issue Oct 11, 2020 · 9 comments
Closed

Reverse sort order? #143

cgoetzke opened this issue Oct 11, 2020 · 9 comments
Assignees
Milestone

Comments

@cgoetzke
Copy link

I think org-ql (with org-super-agenda) is just what I've been looking for to get really useful agendas out of org. But I'm at my wit's end trying to figure out how to get org-ql-search to sort by scheduled descending (newest items on top, oldest on bottom). I might have a custom sort function, but it doesn't look like org-ql-search can do that (I think I got it working with org-ql-select, but then I don't know what to do with the items that returns, and while I'm down to do a little customization, I'm not looking for a big project with this).

I'm hoping you can tell me I'm an idiot and just missed the obvious way to reverse the scheduled sort in org-ql-search.

alphapapa added a commit that referenced this issue Oct 12, 2020
@alphapapa
Copy link
Owner

I'm hoping you can tell me I'm an idiot and just missed the obvious way to reverse the scheduled sort in org-ql-search.

No, I guess that would be me. :) This is, in hindsight, an obvious oversight.

I've pushed a branch that adds a reverse sorting method. It needs polishing and more testing, but it seems to basically work. To reverse the final order, put reverse as the last sorting method.

Ideally, it should be usable multiple times in the list to reverse at different points in the sorting. Or maybe it should be notated like :sort ((reverse scheduled)) rather than :sort (scheduled reverse), so they could be combined like :sort (todo (reverse scheduled)).

Please try the branch and let me know what you think. Thanks.

@alphapapa alphapapa self-assigned this Oct 12, 2020
@alphapapa alphapapa added this to the 0.5 milestone Oct 12, 2020
@cgoetzke
Copy link
Author

Oh, geez. That was quick!

I don't think it's an obvious oversight. It's just one of those things that, once it comes up, makes you say, "Huh. Yeah. That makes sense."

Let me pull the branch and play with it. It might not happen until tomorrow.

But thank you!

alphapapa added a commit that referenced this issue Oct 13, 2020
@cgoetzke
Copy link
Author

cgoetzke commented Oct 14, 2020

Okay, n00b time. I'm not seeing an option to sort reversed (I'm calling org-ql-search interactively; I also use ivy and it's not showing me any new options for sorting).

I've also played some with a compound agenda using org-ql-block; I'll see if I can figure out where to put a :sort on that. Or I'm open to a recommendation on a better method for testing.

Also. When running org-ql-search, I'm getting this error if I use the non-sexp syntax:

let*: Symbol’s function definition is void: peg-parse-string

Specifically, I'm using the search query todo:. But if I make that (todo), it doesn't error out. Not sure if this is interesting, or completely un-related.

Just as a sanity check, I think I'm using the right code, but this branch is a little different than anything I've seen before. I've cloned your repo, and this is what git has to say about my current branch:

[clg@codex6470 org-ql]$ git status
HEAD detached at origin/wip/sort-reversed
nothing to commit, working tree clean

So let me know if I'm going something stupid with git here, too.

@alphapapa
Copy link
Owner

You've described several different issues.

let*: Symbol’s function definition is void: peg-parse-string

That usually indicates an installation problem. You haven't said how you installed or loaded the code in the branch, so I don't know if you've done something wrong. If you search for that error on this issue tracker, you should be able to find discussion about it.

Generally, I would recommend deleting existing versions of the package in your config, then using a tool like Quelpa or Straight to install the package directly from the git branch.

That error could explain the other problems, although it also sounds like you're not very familiar with how queries work in this package or how to enter them. The documentation should cover that thoroughly; please let me know if you find any gaps in it that I need to fill.

I've also played some with a compound agenda using org-ql-block; I'll see if I can figure out where to put a :sort on that. Or I'm open to a recommendation on a better method for testing.

If you look on the tracker, you'll see discussion about adding support for arguments like that to the block function. In the meantime, I'd recommend keeping it simple and just using the org-ql-search command.

alphapapa added a commit that referenced this issue Nov 10, 2020
@alphapapa alphapapa modified the milestones: 0.5, 0.6 Nov 20, 2020
alphapapa added a commit that referenced this issue Jun 18, 2021
This is a breaking change of sorts in that searches using multiple
sorting methods will have to have the order of the sorters reversed to
get the same result.  Unfortunate, but I think it's worth it in the
end, and this is pre-1.0, anyway.

See #143.
@alphapapa
Copy link
Owner

alphapapa commented Jun 18, 2021

Revisiting this, I've pushed a new branch, wip/reverse-sorting2, that:

  1. Adds a reverse sorting method. It can be used like any other, e.g. :sort '(date reverse priority). It can also be used multiple times, at any point in the list of sorters.
  2. Inverts the way sorting methods are applied. This affects all existing user searches that use multiple sorting methods: they will need to invert their sort order by either adding reverse as the final method, or manually inverting the order of the sorting methods. This is an incompatible change that users will have to adjust to, but I think it's worth it, and this is pre-1.0, so occasional, minor such changes are to be expected. I don't think there's a practical way to inform users other than in the changelog.

@cgoetzke Please let me know what you think.

@akirak @yantar92 @munen I'd value your input on this as well.

If there aren't any issues, I'll push this to master soon, and it will be released in 0.6. Thanks.

alphapapa added a commit that referenced this issue Jun 18, 2021
This is a breaking change of sorts in that searches using multiple
sorting methods will have to have the order of the sorters reversed to
get the same result.  Unfortunate, but I think it's worth it in the
end, and this is pre-1.0, anyway.

See #143.
@yantar92
Copy link
Contributor

yantar92 commented Jul 2, 2021

@akirak @yantar92 @munen I'd value your input on this as well.

I have no objections. I never use sorting and org-ql-view :)

@munen
Copy link
Contributor

munen commented Jul 2, 2021

Sounds good to me, too. Nice change 👍

@akirak
Copy link
Contributor

akirak commented Jul 2, 2021

I have no objection, either. Go ahead.

alphapapa added a commit that referenced this issue Jul 13, 2021
This is a breaking change of sorts in that searches using multiple
sorting methods will have to have the order of the sorters reversed to
get the same result.  Unfortunate, but I think it's worth it in the
end, and this is pre-1.0, anyway.

See #143.
alphapapa added a commit that referenced this issue Jul 13, 2021
This is a breaking change of sorts in that searches using multiple
sorting methods will have to have the order of the sorters reversed to
get the same result.  Unfortunate, but I think it's worth it in the
end, and this is pre-1.0, anyway.

See #143.
alphapapa added a commit that referenced this issue Jul 13, 2021
This is a breaking change of sorts in that searches using multiple
sorting methods will have to have the order of the sorters reversed to
get the same result.  Unfortunate, but I think it's worth it in the
end, and this is pre-1.0, anyway.

See #143.
alphapapa added a commit that referenced this issue Jul 13, 2021
This is a breaking change of sorts in that searches using multiple
sorting methods will have to have the order of the sorters reversed to
get the same result.  Unfortunate, but I think it's worth it in the
end, and this is pre-1.0, anyway.

See #143.
@alphapapa
Copy link
Owner

Thanks to all of you for your feedback. This is now merged to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants