Skip to main content

sort-cards

Sets or clears the active sort criterion. Cards in every column are reordered according to the new criterion. Pass null or omit sort to clear and restore source order.

Usage​

interface SortCardsPayload {
sort?: SortCriterion;
}

SortCriterion accepts three forms:

  • (a: KanbanCard, b: KanbanCard) => number - custom comparator
  • { field: string; dir?: "asc" | "desc" } - field-based sort (ascending by default)
  • null - clear the active sort

Trigger​

api.exec("sort-cards", { sort: { field: "priority", dir: "desc" } });
// Custom comparator
api.exec("sort-cards", {
sort: (a, b) => a.label.localeCompare(b.label),
});
// Clear sort
api.exec("sort-cards", { sort: null });

Observe​

api.on("sort-cards", ({ sort }) => {
console.log("Sort changed:", sort);
});

Intercept​

api.intercept("sort-cards", ({ sort }) => {
// Block clearing the sort
return sort !== null;
});

Component handler​

<Kanban :onsortcards="({ sort }) => console.log(sort)" />