Commands for sorting tasks in a note
NOTE: The functions in this plugin were previously part of the "Task Automations" plugin. @eduardme suggested we break out the sorting functions and move them here.
See CHANGELOG for latest updates/changes to this plugin.
Commands for sorting tasks in a note
When sorting tasks, the plugin can handle task types in two ways:
Groups related task types together and sorts them as one unit:
* open tasks + + checklist items (sorted together by priority)* [>] scheduled + + [>] scheduled checklist items* [x] done + + [x] completed checklist items* [-] cancelled + + [-] cancelled checklist itemsResult: 4 logical groups that make more sense for daily use
Example output:
### Open Tasks:
* !!! high priority open task
+ !! medium priority checklist item
* ! low priority open task
+ another checklist item
### Completed Tasks:
* [x] completed task @done(2025-11-06)
+ [x] completed checklist @done(2025-11-06)
Keeps all 8 task types completely separate:
*)+)* [>])+ [>])* [x])+ [x])* [-])+ [-])Result: 8 separate sections (can be verbose for notes with mixed task types)
/ts): Will prompt you to choose each time/tsd, /tsm, /tst, /tsc): Set in Plugin Preferences → "Combine Related Task Types?"true or false as arg4 (interleaveTaskTypes parameter)You can customize the text used for each task type heading in Plugin Preferences:
Headings used when COMBINING task types (recommended mode):
* tasks and + checklist items (e.g., "Tareas Abiertas" in Spanish)* [>] and + [>] items (e.g., "Tâches Planifiées" in French)* [x] and + [x] items (e.g., "已完成" in Chinese)* [-] and + [-] itemsAdditional headings used ONLY in traditional mode (8 separate sections):
+ items only (e.g., "Lista de Verificación")+ [>] items only+ [x] items only+ [-] items onlyTo customize:
Set "Show Empty Task Category Headings?" in Plugin Preferences:
This plugin will sort your tasks in the open note in the Editor interactively so you can choose how you want it to work and output
When you run /ts, it will sort the tasks into task types (open|scheduled|completed|cancelled), and it will ask you how you want to sort within those categories and whether you want the output to have the category type headings or not, e.g.:
arg0: withUserInput (true/false) - whether to prompt user interactivelyarg1: sortFields (comma-separated string) - sort order, e.g. "-priority,content"arg2: withHeadings (true/false) - whether to output section headings like "Open Tasks"arg3: subHeadingCategory (true/false) - whether to output subheadings for each tag/mentionarg4: interleaveTaskTypes (true/false) - whether to interleave task types together or keep separatearg5: sortInHeadings (true/false) - whether to sort within each heading separately or treat entire note as one unit# Sort by priority without headings, treating entire note as one unit (moves all open tasks to top)
noteplan://x-callback-url/runPlugin?pluginID=dwertheimer.TaskSorting&command=Sort%20tasks%20on%20the%20page&arg0=false&arg1=-priority,content&arg2=false&arg3=false&arg4=true&arg5=false
# Sort within each heading separately (default behavior)
noteplan://x-callback-url/runPlugin?pluginID=dwertheimer.TaskSorting&command=Sort%20tasks%20on%20the%20page&arg0=false&arg1=-priority,content&arg2=false&arg3=false&arg4=true&arg5=true
New Feature: Task Type Interleaving (Default Behavior)
Sorting Behavior Options:
sortInHeadings: true (default): Sort tasks within each heading separately. Tasks stay under their original headings but are sorted within each heading.sortInHeadings: false: Treat the entire note as one unit. All open tasks move to the top of the page regardless of which heading they were originally under.interleaveTaskTypes=false#### Open Tasks
- [ ] Open Task
#### Scheduled Tasks
- [>] Forwarded/Scheduled Task >2030-01-01
#### Completed Tasks
- [x] Completed Task
#### Cancelled Tasks
- [-] Cancelled task
Sort the Tasks in the open note by (the first) #Tag and display with subheadings for each unique tag [If you want more granular control over whether there are or aren't headings, use /ts]
Sort the Tasks by Due Date and then Priority [If you want more granular control over whether there are or aren't headings, use /ts]
Sort the Tasks in the open note by (the first) #tag (and then by @Mention) [If you want more granular control over whether there are or aren't headings, use /ts]
Sort the Tasks in the open note by (the first) @Mention and display with subheadings for each unique @mention [If you want more granular control over whether there are or aren't headings, use /ts]
Sort tasks in note by user setting primary/secondary sort fields Set the primary and secondary sort order for this default search in plugin preferences
This command brings all the tasks inside of the currently open note to the top of the note. You can choose whether you want headings (e.g. "Open Tasks", "Sheduled Tasks" etc.) or whether you want just the sorted tasks brought to the top. Note: brings only task lines (not indented underneath)
This command will sort the tasks under a heading that you choose. You can pass the heading as a parameter, or you can choose it interactively. You can also pass the sort order as a parameter, e.g. (["-priority", "content"]), or you can choose it interactively. For example, this command will sort all the tasks under the heading "Open Tasks" by priority and then alphabetically by content.
noteplan://x-callback-url/runPlugin?pluginID=dwertheimer.TaskSorting&command=Sort%20tasks%20under%20heading%20%28choose%29&arg0=Open%20Tasks&arg1=%5B%22-priority%22%2C%22content%22%5D
Sort tasks with interleaving (default behavior):
noteplan://x-callback-url/runPlugin?pluginID=dwertheimer.TaskSorting&command=Sort%20tasks%20on%20the%20page&arg0=false&arg1=-priority%2Ccontent&arg2=false&arg3=false&arg4=true
Sort tasks with traditional grouping (override default):
noteplan://x-callback-url/runPlugin?pluginID=dwertheimer.TaskSorting&command=Sort%20tasks%20on%20the%20page&arg0=false&arg1=-priority%2Ccontent&arg2=false&arg3=false&arg4=false
Sort tasks under heading with interleaving (default):
noteplan://x-callback-url/runPlugin?pluginID=dwertheimer.TaskSorting&command=Sort%20tasks%20under%20heading%20%28choose%29&arg0=Open%20Tasks&arg1=%5B%22-priority%22%2C%22content%22%5D&arg2=null&arg3=true
Sort tasks under heading with traditional grouping:
noteplan://x-callback-url/runPlugin?pluginID=dwertheimer.TaskSorting&command=Sort%20tasks%20under%20heading%20%28choose%29&arg0=Open%20Tasks&arg1=%5B%22-priority%22%2C%22content%22%5D&arg2=null&arg3=false
Parameters explained:
arg0: withUserInput (false = no prompts)arg1: sortFields (comma-separated: "-priority,content")arg2: withHeadings (false = no type headings)arg3: subHeadingCategory (false = no subheadings)arg4: interleaveTaskTypes (true = interleave by priority, false = traditional grouping by type)NOTE: If you are calling this command from a plugin or a template and want to sort tasks under a heading in a specific note (or the Editor) you have been working on, you should pass the note as a third parameter to ensure that taskSorting is working on the same Object you have been working on, e.g. ("myHeading",["-priority","content"], Editor). For clarity, Task Sorting plugin works on Editor.note, but if you are using Editor (and not Note) you should pass Editor in as the noteOverride parameter, else the delayed write from Editor will overwrite any task sorting you do.
This plugin will give you a choice of whether to mark all open tasks as completed or all completed tasks as open.
