diff options
author | 2016-07-30 23:05:20 +0300 | |
---|---|---|
committer | 2016-07-30 23:05:20 +0300 | |
commit | a060c505982ceea5142f78357d42ba2f0de19b60 (patch) | |
tree | 405c759bed8e2c65321e75b1dbeca62320fd9418 /juick-www/src/main/java/com | |
parent | db0c49e8ebd38c5bab5b3f148e0b1ba4b6feccbd (diff) |
www: sort user tags
Diffstat (limited to 'juick-www/src/main/java/com')
-rw-r--r-- | juick-www/src/main/java/com/juick/www/User.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/juick-www/src/main/java/com/juick/www/User.java b/juick-www/src/main/java/com/juick/www/User.java index 1c23864e..3417a3cd 100644 --- a/juick-www/src/main/java/com/juick/www/User.java +++ b/juick-www/src/main/java/com/juick/www/User.java @@ -32,6 +32,7 @@ import java.io.PrintWriter; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.List; +import java.util.stream.Collectors; /** * @@ -321,7 +322,8 @@ public class User { } public static String pageUserTags(JdbcTemplate sql, com.juick.User user, com.juick.User visitor, int cnt) { - List<Tag> tags = TagQueries.getUserTagsAll(sql, user.getUID()); + List<Tag> tags = TagQueries.getUserTagsAll(sql, user.getUID()).stream() + .sorted((e1, e2) -> Integer.compare(e1.UsageCnt, e2.UsageCnt)).collect(Collectors.toList()); int maxUsageCnt = tags.stream().map(t -> t.UsageCnt).max(Integer::max).orElse(0); String ret = ""; int count = cnt > 0 ? Math.min(tags.size(), cnt) : tags.size(); |