obsidian-tasks icon indicating copy to clipboard operation
obsidian-tasks copied to clipboard

Add instruction to sort tasks by line number in the file, in order to preserve the original order

Open thoresson opened this issue 1 year ago • 9 comments

⚠️ Please check that this feature request hasn't been suggested before.

  • [X] I searched previous Ideas in Discussions didn't find any similar feature requests.
  • [X] I searched previous Issues didn't find any similar feature requests.
  • [X] I am only requesting a single feature. Multiple changes should be split into individual requests, with links between them.
  • [X] I believe my requested feature will be generally applicable to other users, not just me: it is not uniquely tied to my personal workflow.

🔖 Feature description

I'm coming from OmniFocus which I've used for over a decade. One of OmniFocus' unique feature is task dependencies, where the order of the tasks in a project can be used to determine which tasks are available and which are blocked by others. Do achieve this, OmniFocus has two different kind of projects: Sequential and Parallel. For sequential projects, only the first task is shown in various views where tasks are filtered based on kind of the same principles as Tasks.

While Tasks doesn't allow for this kind of filtering, I still sort my tasks in the order they can be done, using intendention to make dependencies between task visually distinct.

But I think there might be a way to do something similar with Tasks, should a "Sort by home file order" (or whatever would be a good way to describe this sorting mechanism.

Using "Sort by file order", Tasks would just look at the file from where the tasks are stored and make no changes at all to the sort order. If this is combined with Group by heading and Limit groups 1 and instead of subtasks indented under it's parent divide your project with subheadings, I think the result would be what I would love to have in Obsidian: Only the next available task for each part of a project, selected by the sort order I give them in my project document.

(Side note: This would also be very useful for another query I have in my main project document. There I do this

not done path includes <% tp.file.title %> group by path group by filename group by heading

To include tasks in the main file, and tasks in all other files (like meeting minutes, etc) stored in subfolders. In this case, the Sort by file order would give me a structured overview of my project, the way I intend to do it, and also include all tasks that's spread over all files in a single view. The main file is always getting to the core of the project, while tasks in meeting minutes etc are more of checklist items/reminders.

(The base folder for each project shares the name with my main project document, that's why I can use tp.file.title as a variable for path by the way.)

✔️ Solution

With a project document with this structure:

# Project X ## Part 1 - [ ] Task 1.1 - [ ] Task 1.2 ## Part 2 - [ ] Task 2.1 - [ ] Task 2.2

The query would result in a list with Task 1.1 and Task 2.1, without taking priorities, due dates, etc into account.


Edit from maintainer:

After discussion, the above is an example that shows how the feature might be used in conjunction with other things like grouping and limits.

The specific request is to be able to show tasks in the order they appeared in the markdown file. It can be thought if as 'sort by line number'.


❓ Alternatives

A work around is to group by heading, sort by urgency and limit to 1. If you are consitent with how you use priorities, etc, you could probably reach almost the same result. But you couldn't count on it, I think?

📝 Additional Context

No response

thoresson avatar Aug 14 '23 20:08 thoresson

Hi @thoresson, thanks for writing this up, from your question Discord.

There, you said:

Is there a command for Sort by that let you keep the order the tasks are in the file they are fetched from?

I thought that 'keep the order the tasks are in the file' was very clear, and I interpreted it kind of like 'sort by line number in file'...

Now, reading this request, I think maybe I was misunderstanding...

When I find that after I've read the description of a request several times, and I am not confident that I actually understand the specific request, it's best to ask for a more concrete explanation straight away, whilst it's fresh in the requester's mind - and before too many potential contributors also spend trying to understand...

So, please could you draw us a picture with a few files, and a few tasks in each file, and show exactly what it is that you are wanting.

Also, please make sure that it a single feature.

  • Is it a sorting thing?
  • Is it a grouping thing?
  • Is it a limit thing?

Many thanks.

claremacrae avatar Aug 14 '23 20:08 claremacrae

Or is it really a complex workaround for the lack of Task dependencies?

In which case, would the time be better spent on dependencies than what may be a very specific personal workaround...

claremacrae avatar Aug 14 '23 20:08 claremacrae

Yes, line numbers are of course the correct way to decribe it! But in combination with grouping and limiting, I see it become even more powerful because you could base the results of your query on the freeform structure of a markdown document.

thoresson avatar Aug 14 '23 20:08 thoresson

Yes, line numbers are of course the correct way to decribe it!

That's great. It would really help if you could update the title of the issue, and the Solution section, to say what the request is, please...

image

claremacrae avatar Aug 14 '23 20:08 claremacrae

That's great. It would really help if you could update the title of the issue, and the Solution section, to say what the request is, please...

I've done that...

claremacrae avatar Aug 14 '23 20:08 claremacrae

Yes, line numbers are of course the correct way to decribe it!

That's great. It would really help if you could update the title of the issue, and the Solution section, to say what the request is, please...

image

piggybacking on this with possibly unwanted comment (apologies in advance) - if the entry Task 1.1 was on line number 5, (implying open tasks on lines: 5, 6, skip 8, 9) - is {line number} a field that could be returned to a TABLE? (The eventual goal being able to show next 2 tasks for each of my 5 projects despite each project having 100 open tasks - result count -> 52 instead of 5100.)

chuckthenerd avatar Sep 14 '23 19:09 chuckthenerd

Hi @chuckthenerd, I have read your comment several times and I don’t fully understand what it is asking. But it’s hard enough keeping up with all the discussions in single-topic threads, yet alone responding to unrelated ones.

There is already a label on Issues and Discussions with table in the name. Feel free to search for what is already requested, and if your request is not already covered, create a new issue using the form that requests enough information for your goal to hopefully be unambiguous. Thanks.

claremacrae avatar Sep 14 '23 20:09 claremacrae

Yes, line numbers are of course the correct way to decribe it!

That's great. It would really help if you could update the title of the issue, and the Solution section, to say what the request is, please... image

piggybacking on this with possibly unwanted comment (apologies in advance) - if the entry Task 1.1 was on line number 5, (implying open tasks on lines: 5, 6, skip 8, 9) - is {line number} a field that could be returned to a TABLE? (The eventual goal being able to show next 2 tasks for each of my 5 projects despite each project having 100 open tasks - result count -> 5_2 instead of 5_100.)

RESOLVED - Have just read solution to desired goal within https://publish.obsidian.md/tasks/Queries/Limiting#Limit+number+of+tasks+in+each+group

chuckthenerd avatar Sep 14 '23 21:09 chuckthenerd

See also:

  • https://github.com/obsidian-tasks-group/obsidian-tasks/discussions/506

claremacrae avatar Feb 28 '24 21:02 claremacrae