Problem
sortByDate resolves each project's date as updatedAt || createdAt || null, then converts via new Date(date).getTime(). A truthy-but-unparseable string (e.g. "not-a-date") yields NaN, so the comparator returns NaN and the resulting order is unspecified per the ECMAScript sort contract.
// packages/core/src/lib/sortByDate.ts
const timeA = dateA ? new Date(dateA).getTime() : 0 // 'not-a-date' → NaN
return (timeA - timeB) * multiplier // NaN
Context
Proposal
Coerce NaN to 0 in the comparator so unparseable dates degrade to dateless (epoch-equivalent, oldest) rather than poisoning the sort:
const timeA = dateA ? new Date(dateA).getTime() || 0 : 0
(|| 0 also swallows a literal epoch 0, which is acceptable — it already ties with dateless per #23.)
Problem
sortByDateresolves each project's date asupdatedAt || createdAt || null, then converts vianew Date(date).getTime(). A truthy-but-unparseable string (e.g."not-a-date") yieldsNaN, so the comparator returnsNaNand the resulting order is unspecified per the ECMAScript sort contract.Context
Proposal
Coerce
NaNto0in the comparator so unparseable dates degrade to dateless (epoch-equivalent, oldest) rather than poisoning the sort:(
|| 0also swallows a literal epoch0, which is acceptable — it already ties with dateless per #23.)