@get:JvmName("niceNameComparator") // TODO: remove once Sone is 100% Kotlin
val niceNameComparator: Comparator<Sone> =
comparing(SoneAccessor::getNiceName, caseInsensitiveCompare).thenComparing(Sone::id)
+
+/**
+ * Comparator that sorts Sones by their [last activity][Sone.getTime], least
+ * recently active Sones first.
+ */
+@get:JvmName("lastActivityComparator") // TODO: remove once Sone is 100% Kotlin
+val lastActivityComparator: Comparator<Sone> =
+ comparing(Sone::getTime).reversed()
+
+/**
+ * Comparator that sorts Sones by their [post count][Sone.getPosts] (most posts
+ * first) and, failing that, by their [reply count][Sone.getReplies] (most
+ * replies first).
+ */
+@get:JvmName("postCountComparator") // TODO: remove once Sone is 100% Kotlin
+val postCountComparator: Comparator<Sone> =
+ comparing<Sone, Int> { it.posts.size }
+ .thenComparing<Int> { it.replies.size }
+ .reversed()
+
+val imageCountComparator: Comparator<Sone> =
+ comparing<Sone, Int> { it.rootAlbum.allImages.size }.reversed()
+
+val Sone.allAlbums: List<Album>
+ get() =
+ rootAlbum.albums.flatMap(Album::allAlbums)
+
+val Sone.allImages: Collection<Image>
+ get() =
+ rootAlbum.allImages