[英]How to sort cron expressions in typescript?
I am working on an angularjs application, and I need to sort in ascending order a list of jobs by schedule attribute (which is a cron expression that could be hourly, daily, monthly, quarterly, yearly, etc), Example:我正在开发一个 angularjs 应用程序,我需要按计划属性(这是一个可以是每小时、每天、每月、每季度、每年等的 cron 表达式)对作业列表进行升序排序,例如:
[
0: object{ schedule: '0 0 2 * * ?' },
1: object{ schedule: '0 0 10 * * ? '},
2: object{ schedule: '0 0 23 * * ? ' },
3: object{ schedule: '0 0 20 * * ? ' },
4: object{ schedule: '0 0 3 * * ? ' },
5: object{ schedule: '0 55 * * * ? ' }
]
What i want to achieve:我想要达到的目标:
[
0: object{ schedule: '0 55 * * * ? ' },
1: object{ schedule: '0 0 2 * * ?' },
2: object{ schedule: '0 0 3 * * ? ' },
3: object{ schedule: '0 0 10 * * ? '},
4: object{ schedule: '0 0 20 * * ? ' },
5: object{ schedule: '0 0 23 * * ? ' }
]
I already use cronstrue library to make cron expressions more human readable, , i thought about parsing the expressions and manually sort them, but it turned out to have many edge cases to handle, any suggestions how to achieve sorting of a list of cron jobs in typescript?我已经使用cronstrue库使 cron 表达式更具人类可读性,我考虑过解析表达式并手动对它们进行排序,但结果证明有许多边缘情况需要处理,任何建议如何实现对 cron 作业列表的排序typescript?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.