export interface SchedulingPriorityRow { isGovernment?: boolean; priorityScore?: number; scheduledDate: string; } /** Government first, then priority score, then earliest scheduled date. */ export function compareSchedulingPriority( a: SchedulingPriorityRow, b: SchedulingPriorityRow, ): number { const govDiff = Number(Boolean(b.isGovernment)) - Number(Boolean(a.isGovernment)); if (govDiff !== 0) return govDiff; const priorityDiff = (b.priorityScore ?? 0) - (a.priorityScore ?? 0); if (priorityDiff !== 0) return priorityDiff; return new Date(a.scheduledDate).getTime() - new Date(b.scheduledDate).getTime(); }