mirror of
https://github.com/stablyai/orca.git
synced 2026-09-23 16:02:24 +00:00
* 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>
12 lines
454 B
TypeScript
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)!)
|
|
}
|