From: David ‘Bombe’ Roden Date: Wed, 16 Jan 2013 14:15:53 +0000 (+0100) Subject: Use Guava to sort the hits. X-Git-Tag: 0.8.5^2~3^2~123 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=13e6ab1c63ed982d5be1dd2f436b8af79acd8fd6 Use Guava to sort the hits. --- diff --git a/src/main/java/net/pterodactylus/sone/web/SearchPage.java b/src/main/java/net/pterodactylus/sone/web/SearchPage.java index 355df1b..08b6ccc 100644 --- a/src/main/java/net/pterodactylus/sone/web/SearchPage.java +++ b/src/main/java/net/pterodactylus/sone/web/SearchPage.java @@ -50,6 +50,7 @@ import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.google.common.collect.Collections2; import com.google.common.collect.FluentIterable; +import com.google.common.collect.Ordering; /** * This page lets the user search for posts and replies that contain certain @@ -138,10 +139,8 @@ public class SearchPage extends SoneTemplatePage { postHits = Collections2.filter(postHits, Hit.POSITIVE_FILTER); /* now sort. */ - List> sortedSoneHits = new ArrayList>(soneHits); - Collections.sort(sortedSoneHits, Hit.DESCENDING_COMPARATOR); - List> sortedPostHits = new ArrayList>(postHits); - Collections.sort(sortedPostHits, Hit.DESCENDING_COMPARATOR); + List> sortedSoneHits = Ordering.from(Hit.DESCENDING_COMPARATOR).sortedCopy(soneHits); + List> sortedPostHits = Ordering.from(Hit.DESCENDING_COMPARATOR).sortedCopy(postHits); /* extract Sones and posts. */ List resultSones = FluentIterable.from(sortedSoneHits).transform(new HitMapper()).toList();