🎨 Replace NEWEST_FIRST comparator with Kotlin version
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / data / Post.kt
index 7041561..955196a 100644 (file)
@@ -1,8 +1,16 @@
 package net.pterodactylus.sone.data
 
+import java.util.Comparator.comparing
+
 /**
  * Predicate that returns whether a post is _not_ from the future,
  * i.e. whether it should be visible now.
  */
 @get:JvmName("noFuturePost")
 val noFuturePost: (Post) -> Boolean = { it.time <= System.currentTimeMillis() }
+
+/**
+ * Comparator that orders posts by their time, newest posts first.
+ */
+@get:JvmName("newestFirst")
+val newestFirst: Comparator<Post> = comparing(Post::getTime).reversed()