From b85d585d5325baff5332dd2946c7d6728fde3cc4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 19 Apr 2012 15:03:16 +0200 Subject: [PATCH] Add sort filter for tracks. --- .../net/pterodactylus/demoscenemusic/core/TemplateServlet.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/net/pterodactylus/demoscenemusic/core/TemplateServlet.java b/src/main/java/net/pterodactylus/demoscenemusic/core/TemplateServlet.java index 1b1ce58..739f16c 100644 --- a/src/main/java/net/pterodactylus/demoscenemusic/core/TemplateServlet.java +++ b/src/main/java/net/pterodactylus/demoscenemusic/core/TemplateServlet.java @@ -38,6 +38,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.pterodactylus.demoscenemusic.data.Artist; +import net.pterodactylus.demoscenemusic.data.Track; import net.pterodactylus.demoscenemusic.page.ServletRequest; import net.pterodactylus.util.io.Closer; import net.pterodactylus.util.io.StreamCopier; @@ -88,6 +89,14 @@ public class TemplateServlet extends HttpServlet { } }); + sortFilter.addComparator(Track.class, new Comparator() { + + @Override + public int compare(Track leftTrack, Track rightTrack) { + return leftTrack.name().compareToIgnoreCase(rightTrack.name()); + } + + }); templateContextFactory.addFilter("sort", sortFilter); templateContextFactory.addTemplateObject("core", core); -- 2.7.4