diff --git a/src/components/assignment-panel/assignments-list/assignments-list.tsx b/src/components/assignment-panel/assignments-list/assignments-list.tsx index b61de66..778b10e 100644 --- a/src/components/assignment-panel/assignments-list/assignments-list.tsx +++ b/src/components/assignment-panel/assignments-list/assignments-list.tsx @@ -127,9 +127,14 @@ const AssignmentsBucket = ({ }: AssignmentsBucketProps) => { const [expanded, setExpanded] = useState(defaultExpanded) - const assignmentsSource = useMemo(() => ( - assignments?.sort((a, b) => (a.adjustedDueDate?.getTime() ?? 0) - (b.adjustedDueDate?.getTime() ?? 0)) - ), [assignments]) + const assignmentsSource = useMemo(() => assignments?.sort((a, b) => { + const aDue = a.adjustedDueDate?.getTime() ?? Infinity + const bDue = b.adjustedDueDate?.getTime() ?? Infinity + // Sort by date, or name if same date. + if (aDue > bDue) return 1 + if (aDue < bDue) return -1 + return a.name.localeCompare(b.name, undefined, { numeric: true }) + }), [assignments]) const isEmpty = useMemo(() => !assignmentsSource || assignmentsSource.length === 0, [assignmentsSource])