Allow sorting styles.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 19 Apr 2012 15:47:19 +0000 (17:47 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 19 Apr 2012 15:47:19 +0000 (17:47 +0200)
src/main/java/net/pterodactylus/demoscenemusic/core/TemplateServlet.java

index 739f16c..acbb034 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.Style;
 import net.pterodactylus.demoscenemusic.data.Track;
 import net.pterodactylus.demoscenemusic.page.ServletRequest;
 import net.pterodactylus.util.io.Closer;
@@ -97,6 +98,14 @@ public class TemplateServlet extends HttpServlet {
                        }
 
                });
+               sortFilter.addComparator(Style.class, new Comparator<Style>() {
+
+                       @Override
+                       public int compare(Style leftStyle, Style rightStyle) {
+                               return leftStyle.name().compareToIgnoreCase(rightStyle.name());
+                       }
+
+               });
                templateContextFactory.addFilter("sort", sortFilter);
 
                templateContextFactory.addTemplateObject("core", core);