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?"arg4 — true to combine related task types, false for eight separate groups (see X-callback URL examples)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.:
NotePlan passes these in order as arg0, arg1, … in the URL:
arg0: true = show the usual questions in NotePlan; false = skip prompts and use the other args you supplyarg1: Sort order, comma-separated, e.g. -priority,contentarg2: true = add type headings (e.g. “Open Tasks”); false = do not add those headingsarg3: true = add subheadings when sorting by tag or mention; false = no subheadingsarg4: true = combine related types (open tasks and checklists together, etc.); false = eight separate groupsarg5: true = sort within each heading on its own; false = treat the whole note as one block (tasks can move to the top of the note)X-callback links only use arg0–arg5. There is no URL form for passing a note object; see Templates and plugins below if you need that.
# 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 (same ideas as arg5 and arg4 above):
arg5 true (typical): Sort within each heading. Tasks stay under the heading they were under, but order changes inside that section.arg5 false: One sort for the whole note; open tasks can move to the very top of the note.arg4 false (separate open vs checklist sections, etc.).#### 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
Important: Sort tasks on the page and Sort tasks under heading (choose) use different arg0, arg1, … meanings. Use the parameter list that matches the command in your URL.
Use the full parameter list under /ts above (arg0 through arg5).
Combined task types (default style):
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
Eight separate task-type groups instead:
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
arg0: The heading text to sort under (URL-encoded), e.g. Open%20Tasksarg1: How to sort — either a comma-separated list or a JSON array string like ["-priority","content"]arg2: For normal x-callback links, use null or leave it off if your tool allows. (Some automations need this to point at a specific note — see the note below.)arg3: true = combine related open/checklist types; false = eight separate groupsCombined task types under that heading:
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
Eight separate groups under that heading:
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
Note for templates and other plugins: If you run Sort tasks under heading from automation while the editor is open, you may need to pass the open note (or editor) as the third value so sorting applies to the same note you are editing. Otherwise a pending editor save can undo the sort.
Editor or a Note)From Templating, Shortcuts, or another plugin you can pass Editor or a Note so the command sorts that object instead of relying only on whatever Editor.note happens to be at that moment (helps avoid a stale save overwriting your sort).
Editor or Note as the seventh argument after the six sort options (prompts, sort fields, headings, subheadings, combine types, sort-in-headings)./tsd), by due date (/tsc), by @mention (/tsm), by #tag (/tst), tag + mention (/tstm), Tasks to Top (/tt) — One optional argument: pass Editor or the Note to sort. If you omit it, behavior is the same as before (uses the open note in the editor).Editor (see the x-callback section above).Mark tasks (/mat) and the copy-tag tools still only use the open editor; they do not take a note override yet.
This plugin will give you a choice of whether to mark all open tasks as completed or all completed tasks as open.
