From 1a525d6e5d2db95447049ce6cc45bea8bb3a9553 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Fri, 6 Oct 2023 13:46:22 +0530 Subject: [PATCH] fix(android): avoid violating sorting contract Fixes COMPOSE-LOBSTERS-1J --- .../dev/msfjarvis/claw/android/viewmodel/ClawViewModel.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/android/src/main/kotlin/dev/msfjarvis/claw/android/viewmodel/ClawViewModel.kt b/android/src/main/kotlin/dev/msfjarvis/claw/android/viewmodel/ClawViewModel.kt index 3f74265d..f6d42648 100644 --- a/android/src/main/kotlin/dev/msfjarvis/claw/android/viewmodel/ClawViewModel.kt +++ b/android/src/main/kotlin/dev/msfjarvis/claw/android/viewmodel/ClawViewModel.kt @@ -100,7 +100,10 @@ constructor( var searchQuery by mutableStateOf("") private fun mapSavedPosts(items: List): ImmutableMap> { - val sorted = items.sortedByDescending { post -> post.createdAt.toLocalDateTime() } + val sorted = + items.sortedWith { post1, post2 -> + post2.createdAt.toLocalDateTime().compareTo(post1.createdAt.toLocalDateTime()) + } return sorted.groupBy { post -> post.createdAt.toLocalDateTime().month }.toImmutableMap() }