UNPKG

sanity

Version:

Sanity is a real-time content infrastructure with a scalable, hosted backend featuring a Graph Oriented Query Language (GROQ), asset pipelines and fast edge caches

21 lines (18 loc) 595 B
import {type Schedule} from '../types' import {getLastExecuteDate} from './scheduleUtils' export function sortByExecuteDate({reverseOrder}: {reverseOrder: boolean} = {reverseOrder: false}) { return function (a: Schedule, b: Schedule): number { const aExecuteDate = getLastExecuteDate(a) const bExecuteDate = getLastExecuteDate(b) if (aExecuteDate === bExecuteDate) { return 0 } if (aExecuteDate === null) { return 1 } if (bExecuteDate === null) { return -1 } return (aExecuteDate > bExecuteDate ? 1 : -1) * (reverseOrder ? -1 : 1) } }