Files
orca/src/shared/updated-at-order.ts
e373c89536 perf: cache update timestamps for Linear and Jira result sorting (#19473)
* perf: cache update timestamps for Linear and Jira result sorting

* perf(issues): build updatedAt key map without an intermediate tuple array

---------

Co-authored-by: m4air <m4air@m4airs-MacBook-Air.local>
Co-authored-by: Neil <neil@stably.ai>
2026-09-08 19:44:13 -07:00

12 lines
454 B
TypeScript

/** Sorts in place; invalid dates retain the native comparator's stable tie behavior. */
export function sortByUpdatedAtDescending<T extends { updatedAt: string }>(items: T[]): T[] {
if (items.length < 2) {
return items
}
const timestamps = new Map<T, number>()
for (const item of items) {
timestamps.set(item, new Date(item.updatedAt).getTime())
}
return items.sort((left, right) => timestamps.get(right)! - timestamps.get(left)!)
}