X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=blobdiff_plain;f=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FPost.kt;fp=src%2Fmain%2Fkotlin%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FPost.kt;h=955196a0399325e7542c3c8eb337f8fc8d445c1e;hp=70415618621a326f713b386b5eb3697df2fe8c99;hb=37ac474440aec3141cf609af25ee2332724dc7e4;hpb=ee39c03a6a811300728183552afcede1d9f8e79a diff --git a/src/main/kotlin/net/pterodactylus/sone/data/Post.kt b/src/main/kotlin/net/pterodactylus/sone/data/Post.kt index 7041561..955196a 100644 --- a/src/main/kotlin/net/pterodactylus/sone/data/Post.kt +++ b/src/main/kotlin/net/pterodactylus/sone/data/Post.kt @@ -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 = comparing(Post::getTime).reversed()