From 9f39baa5638210e7e7345249da9bb7271b7454d6 Mon Sep 17 00:00:00 2001 From: Christoph Hagen Date: Tue, 7 Jan 2025 10:32:20 +0100 Subject: [PATCH] Sort posts by date --- .../Generator/Post Lists/PostListPageGenerator.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHDataManagement/Generator/Post Lists/PostListPageGenerator.swift b/CHDataManagement/Generator/Post Lists/PostListPageGenerator.swift index a00e74a..1296d88 100644 --- a/CHDataManagement/Generator/Post Lists/PostListPageGenerator.swift +++ b/CHDataManagement/Generator/Post Lists/PostListPageGenerator.swift @@ -21,6 +21,8 @@ final class PostListPageGenerator { } func createPages(for posts: [Post]) { + // Sort by newest first + let posts = posts.sorted(ascending: false) { $0.startDate } let totalCount = posts.count guard totalCount > 0 else { // Create one empty page