Tasks plugin: sort/group headings in order of appearance

What I’m trying to do

I am trying to use a Tasks block (from the Tasks plugin) to group tasks by heading, which is the day of the week, from within a note that was created using the Kanban board plugin.

I want the day of the week to be in the same order that it is written in the note (i.e., in the order of the actual days of the week), but I can’t find documentation about how to do this.

The actual Markdown source of the kanban board is fairly plain, like this:

### Monday
 - [ ] Chili
### Tuesday
 - [ ] Tacos
### Wednesday
 - [ ] Nachos
### Thursday
 - [ ] Chicken Tortilla Soup
### Friday
 - [ ] Chicken and Barley Soup

The Tasks block that I currently have lists the headings and groups accordingly, but it sorts alphabetically rather than by the day of the week:

short mode
filter by function task.file.filename.includes("Weekly Menu")
filter by function task.heading.includes("day")
group by heading

Things I have tried

I’m not really sure how to sort a grouping based on a property that isn’t tied to some kind of metadata field or date. I don’t really know any JavaScript. The only thing that seemed to work was prepending numbers to each heading, which will require a regex replacement so as to achieve the desired result:

### 01 Monday
### 02 Tuesday
### 03 Wednesday

While this will work, I was hoping that someone more experienced than me might have a more elegant solution.

I also saw a previous post that I believe had the same problem, but the original poster mistakenly thought it was a Dataview query so no one was able to help them. So maybe this will help others.

So, I’m more of a Dataview guy, but I’ve used a trick in some queries there which you might benefit from. That is to use hidden comments to facilitate sort order. Not sure if it’ll work for you, but you could try doing ### %%1%% Monday and so on.

If Tasks facilitates the entire heading text when sorting, and not just the visual appearance, you can sort on headings, but keep the order of days in the week using this trick.

1 Like

Perfect, that’s exactly what I was looking for: something simple and easy. This worked excellently. Much appreciated!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.