X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Fdata%2FSoneShell.java;h=16afea1db94925464e57fc732ff2fffb22094b00;hb=5391ee6663db685d2e6283117ff8a17e91165350;hp=8d8690acefbb8815ffb9e86f001111d4b9fb5d03;hpb=5b98dca934a0901a9d2019ee2c51e3979d1c6c15;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/data/SoneShell.java b/src/main/java/net/pterodactylus/sone/data/SoneShell.java index 8d8690a..16afea1 100644 --- a/src/main/java/net/pterodactylus/sone/data/SoneShell.java +++ b/src/main/java/net/pterodactylus/sone/data/SoneShell.java @@ -19,6 +19,7 @@ package net.pterodactylus.sone.data; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -221,13 +222,22 @@ public class SoneShell extends Sone implements Shell { } /** - * Returns the list of posts of this Sone. + * Returns the list of posts of this Sone, sorted by time, newest first. * * @return All posts of this Sone */ @Override public List getPosts() { - return Collections.unmodifiableList(posts); + List sortedPosts = new ArrayList(posts); + Collections.sort(sortedPosts, new Comparator() { + + @Override + public int compare(Post leftPost, Post rightPost) { + return (int) Math.max(Integer.MIN_VALUE, Math.min(Integer.MAX_VALUE, rightPost.getTime() - leftPost.getTime())); + } + + }); + return sortedPosts; } /**