Skip to main content

Sorting and filtering tasks

Sort tasks

After initialization, sort tasks in one of two ways:

  • through the Sort by option of the Toolbar menu — sort tasks by text, due date, completion date, creation date, or editing date
  • through the setSort() method — specify a custom sort function or sort by a task attribute

The example below sorts tasks by id in ascending order:

list.setSort({
by: task => task.id, // or by: "text"
dir: "asc",
// tree: true // enable tree sort, false by default
});

Filter tasks

Filter tasks in one of two ways:

  • through the search bar of the Toolbar
  • through the setFilter() method — supports the strict mode for exact-match filtering

The snippet below filters tasks by a specific hashtag in strict mode:

// filter data by the specified rules
list.setFilter({
match: "#tag1",
highlight: true,
strict: true
});

To reset filtering, pass match: null:

// reset filtering
list.setFilter({ match: null });