Add sort filter for tracks.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 19 Apr 2012 13:03:16 +0000 (15:03 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 19 Apr 2012 13:03:16 +0000 (15:03 +0200)
src/main/java/net/pterodactylus/demoscenemusic/core/TemplateServlet.java

index 1b1ce58..739f16c 100644 (file)
@@ -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<Track>() {
+
+                       @Override
+                       public int compare(Track leftTrack, Track rightTrack) {
+                               return leftTrack.name().compareToIgnoreCase(rightTrack.name());
+                       }
+
+               });
                templateContextFactory.addFilter("sort", sortFilter);
 
                templateContextFactory.addTemplateObject("core", core);