[Schmitzm-commits] r2143 - trunk/schmitzm-core/src/main/java/de/schmitzm/lang

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Tue Nov 13 21:06:10 CET 2012


Author: mojays
Date: 2012-11-13 21:06:10 +0100 (Tue, 13 Nov 2012)
New Revision: 2143

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
Log:
LangUtil: new method to sort a list (naive!)

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java	2012-11-12 22:32:11 UTC (rev 2142)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/lang/LangUtil.java	2012-11-13 20:06:10 UTC (rev 2143)
@@ -2651,14 +2651,14 @@
      *                 source list will be changed!)
      */
     public static <T> List<T> sortList(List<T> sourceList, Comparator<T> comparator, List<T> destList) {
-      if ( destList == null ) {
+      if ( destList == null )
         destList = sourceList;
-        destList.clear();
-      }
       // Sort items in TreeSet
       TreeSet<T> resultSorted = new TreeSet<T>(comparator);
       resultSorted.addAll(sourceList);
-      // But items (now sorted) in destination list
+      // Put items (now sorted) in destination list
+      if (destList == sourceList)
+        destList.clear();
       destList.addAll(resultSorted);
       
       return destList;



More information about the Schmitzm-commits mailing list