+
+/**
+ * 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