Sortable Minimum shape required for topological sorting.
id
type
stringdepends_on
type
Array<string>Generic topological sort using Kahn's algorithm.
Orders items so that dependencies come before dependents.
Works with any item type that has id and optional depends_on.
3 declarations
Sortable Minimum shape required for topological sorting.
idstringdepends_onArray<string><T extends Sortable>(items: T[], label?: string): TopologicalSortResult<T> Sort items by their dependencies using Kahn's algorithm.
Returns items ordered so that dependencies come before dependents. If a cycle is detected, returns an error with the cycle path.
itemsarray of items to sort
T[]labellabel for error messages (e.g. "resource", "step")
string'item'TopologicalSortResult<T> sorted items or error if cycle detected
TopologicalSortResult<T> Result of topological sort.
T