Merge branch 'develop' into termSearch
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / model / DefaultTermComparator.java
index 5918cda845a3ba126fc62521e56e78a2d0096d08..9abcbb67d8c649259f56e52d9856625842f12f67 100644 (file)
@@ -1,9 +1,8 @@
-// $Id$
 /**
 * Copyright (C) 2009 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
-* 
+*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * See LICENSE.TXT at the top of this package for the full license terms.
 */
@@ -18,7 +17,7 @@ import eu.etaxonomy.taxeditor.store.CdmStore;
  * Implements a {@link Comparator} for {@link DefinedTermBase} objects based on the term's label.
  * The compare algorithm compares a term's label. Example: If used on an unsorted list of terms, the
  * list will be alphabetically  sorted by label afterwards.
- * 
+ *
  * @author n.hoffmann
  * @date Jan 18, 2012
  *
@@ -37,6 +36,10 @@ public class DefaultTermComparator<T extends DefinedTermBase> implements Compara
                }
                String label1 = o1.getLabel(CdmStore.getDefaultLanguage()) != null ? o1.getLabel(CdmStore.getDefaultLanguage()) : o1.getTitleCache();
                String label2 = o2.getLabel(CdmStore.getDefaultLanguage()) != null ? o2.getLabel(CdmStore.getDefaultLanguage()) : o2.getTitleCache();
-               return label1.compareTo(label2);
+               int result = label1.compareTo(label2);
+               if (result == 0){
+                   return o1.getUuid().compareTo(o2.getUuid());
+               }
+               return result;
        }
 };