fix(android): avoid violating sorting contract

Fixes COMPOSE-LOBSTERS-1J
This commit is contained in:
Harsh Shandilya 2023-10-06 13:46:22 +05:30
parent bc213fe3c9
commit 1a525d6e5d
No known key found for this signature in database

View file

@ -100,7 +100,10 @@ constructor(
var searchQuery by mutableStateOf("")
private fun mapSavedPosts(items: List<SavedPost>): ImmutableMap<Month, List<SavedPost>> {
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()
}