Sort routes by priority and specificity Routes with lower priority numbers are placed first Within same priority, more specific routes come first
Routes to sort
Sorted routes (does not mutate input)
const routes = [ { match: [{ path: ["/*"] }] }, // Wildcard { match: [{ path: ["/health"] }] }, // Health { match: [{ path: ["/api/*"] }] }, // API];const sorted = sortRoutes(routes);// Order: health, api, wildcard Copy
const routes = [ { match: [{ path: ["/*"] }] }, // Wildcard { match: [{ path: ["/health"] }] }, // Health { match: [{ path: ["/api/*"] }] }, // API];const sorted = sortRoutes(routes);// Order: health, api, wildcard
Sort routes by priority and specificity Routes with lower priority numbers are placed first Within same priority, more specific routes come first