Add comparator for groups.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 31 Jul 2012 05:08:10 +0000 (07:08 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 31 Jul 2012 05:08:10 +0000 (07:08 +0200)
src/main/java/net/pterodactylus/demoscenemusic/data/DefaultGroup.java

index 407a425..57cbf40 100644 (file)
@@ -18,6 +18,7 @@
 package net.pterodactylus.demoscenemusic.data;
 
 import java.util.Collection;
+import java.util.Comparator;
 
 /**
  * Default implementation of a group data container.
@@ -26,6 +27,16 @@ import java.util.Collection;
  */
 public class DefaultGroup extends DefaultBase implements Group {
 
+       /** Comparator that sorts groups by name. */
+       public static final Comparator<Group> NAME_COMPARATOR = new Comparator<Group>() {
+
+               @Override
+               public int compare(Group leftGroup, Group rightGroup) {
+                       return leftGroup.getName().compareToIgnoreCase(rightGroup.getName());
+               }
+
+       };
+
        /**
         * Creates a new group data container.
         *