From 87fd2492e0cbe2a46bcba0c3b4174de69caf0f42 Mon Sep 17 00:00:00 2001 From: leewyatt Date: Wed, 10 Jul 2024 22:08:48 +0900 Subject: [PATCH] Sort blog posts by date Added a line of code to sort blog posts in descending order based on their published date. This ensures that the most recent posts appear first in the MobileBlogOverviewBox. --- .../jfxcentral2/mobile/components/MobileBlogOverviewBox.java | 1 + 1 file changed, 1 insertion(+) diff --git a/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/components/MobileBlogOverviewBox.java b/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/components/MobileBlogOverviewBox.java index a049670f..f770eb0a 100644 --- a/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/components/MobileBlogOverviewBox.java +++ b/mobile/src/main/java/com/dlsc/jfxcentral2/mobile/components/MobileBlogOverviewBox.java @@ -65,6 +65,7 @@ protected Task createTask() { @Override protected Void call() throws InterruptedException { List posts = DataRepository2.getInstance().loadPosts(blog); + posts.sort((o1, o2) -> o2.getSyndEntry().getPublishedDate().compareTo(o1.getSyndEntry().getPublishedDate())); Thread.sleep(500); Platform.runLater(() -> { listView.getItems().setAll(posts);