obsidian-tasks-group / obsidian-tasks

Task management for the Obsidian knowledge base.
https://publish.obsidian.md/tasks/
MIT License
2.5k stars 231 forks source link

Ability to sort groups by some user-defined property calculated from all the tasks in the group, such as most recent due date #1939

Open rhhub opened 1 year ago

rhhub commented 1 year ago

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

🔖 Feature description

This feature request encompasses using "group by" then sorting the groups by the content of each group.

Possible Usecases

  1. sort groups by the highest priority task in each group
  2. sort groups by the soonest due/scheduled/created task in each group
  3. sort groups by some special aggregate calculation of each group (less useful and more complicated)

For Comparison Image

t/group2 should come first because item 1 has the soonest date ⏳ 2023-05-10

image

Desired Image

notice group2 is above group1 image

✔️ Solution

I'm not sure what the solution would be. I think it would be called on the group by line.

Tasks' Steps

  1. Query tasks
  2. Display groups using group by
  3. Sort the groups by content in each group.

Users Steps

  1. Provide query language to modify group by order

Where user implements sort logic:

```tasks
not done
group by tags SOME CALL HERE
sort by priority

### ❓ Alternatives

I noticed #1421 had some functions added to the group by call. I'm not sure the extent of that addition.

### 📝 Additional Context

### markdown of first screenshot:
not done
group by tags
sort by priority
claremacrae commented 1 year ago

Hi @rhhub, Thank you for the write-up.

I regret to say that I have read it multiple times and am not at all confident that I understand what exact change in Tasks functionality it is requesting.

This feature request is made to satisfy the following statement: Grab the next task then get all tasks that share context with it. If I have tasks labeled #grocerystore, it would be helpful to get all tags that share grocerystore.

For example, I am struggling to understand what "If I have tasks labeled #grocerystore, it would be helpful to get all tags that share grocerystore. " means...

Especially as the example tasks you give do not mention #grocerystore - so I cannot see how the tags relate to the request.

I think that what you are saying is:

If you could please provide a more concrete description of the real-world problem you are trying to solve, maybe I can make suggestions. Thanks.

In case you don't know, it's possible to give multiple sort by instructions in tasks blocks. The first sort line takes precedence, but where 2 or more tasks have the same value for the first sort line, they are compared/sorted by the second sort line, and so on...

So you have a lot of control over the sort of tasks within groups.

What is currently not yet possible is to control the order of the groups themselves.

rhhub commented 1 year ago

Hi,

I updated the original post. It does require sorting groups. I think it's less ambiguous now.

One example: I want to sort the groups. When I "group by", each of those groups contain tasks. Steps to sort groups:

  1. In a single group find the task with the highest priority.
  2. Sort the groups by each respective priority found in step 1
claremacrae commented 1 year ago

OK, I get it. Thank you very much indeed.

I've updated the description/summary to try to make it fully reflect the request.

Just to set expectations, the current code design is a long way off being able to sort this.

rhhub commented 1 year ago

That's fair. Your help in #1940 will get me by with use tag contexts more. Thank you.