tickle/modules/tickle/sortFileListLines.mjs
2023-05-09 04:00:53 +02:00

15 lines
390 B
JavaScript

//@ts-check
/**
* @typedef {import("./parseFileList.mjs").ParsedLine} ParsedLine
*/
/**
* Sorts a list of parsed lines by a given property in-place
* @param {ParsedLine[]} lines
* @param {keyof ParsedLine} property
*/
export const sortFileListLines = (lines, property = 'date_unix') =>
lines.sort(({ [property]: a }, { [property]: b }) => a - b);
export default sortFileListLines