Skip to content

Commit

Permalink
sort assn alphanum if due date tied
Browse files Browse the repository at this point in the history
  • Loading branch information
frostyfan109 committed Aug 27, 2024
1 parent 0821a3a commit a052dec
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,14 @@ const AssignmentsBucket = ({
}: AssignmentsBucketProps) => {
const [expanded, setExpanded] = useState<boolean>(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])

Expand Down

0 comments on commit a052dec

Please sign in to comment.