+9
src/scripts/sorter.ts
+9
src/scripts/sorter.ts
···
9
9
};
10
10
};
11
11
12
+
/**
13
+
* Can be used for any `ContentCollection` that has a `data.date` field to sort
14
+
* by it.
15
+
*
16
+
* @param a first item to compare
17
+
* @param b second item to compare
18
+
* @returns positive number if `a` is older than `b`, negative number if `a` is
19
+
* newer than `b`
20
+
*/
12
21
export const byDate = (a: DateSortable, b: DateSortable): number =>
13
22
b.data.date.getTime() - a.data.date.getTime();