diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/CachedResultSetManager.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/CachedResultSetManager.java
index e460eb64746d7ccf87cdb14d29bfae93c82f93dc..fdcb552bb2c18c2da6367e5102e7a897c3a86e40 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/CachedResultSetManager.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/CachedResultSetManager.java
@@ -26,8 +26,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.commons.collections.comparators.NullComparator;
-import org.apache.commons.collections.comparators.ReverseComparator;
+import org.apache.commons.collections.ComparatorUtils;
 import org.apache.commons.lang.text.StrMatcher;
 import org.apache.commons.lang.text.StrTokenizer;
 import org.apache.log4j.Logger;
@@ -266,8 +265,8 @@ public final class CachedResultSetManager<K> implements IResultSetManager<K>, Se
 
             };
 
-        // null values will be treated as smallestte
-        return applySortDir(sortDir, new NullComparator(comparator, false));
+        // null values will be treated as smallest
+        return applySortDir(sortDir, ComparatorUtils.nullLowComparator(comparator));
     }
 
     @SuppressWarnings("unchecked")
@@ -275,7 +274,7 @@ public final class CachedResultSetManager<K> implements IResultSetManager<K>, Se
     {
         if (sortDir == SortDir.DESC)
         {
-            return new ReverseComparator(comparator);
+            return ComparatorUtils.reversedComparator(comparator);
         } else
         {
             return comparator;
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/PrimitiveValueTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/PrimitiveValueTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..188c295ce38677a0cb26395cdd05d33827679b12
--- /dev/null
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/PrimitiveValueTest.java
@@ -0,0 +1,99 @@
+package ch.systemsx.cisd.openbis.generic.shared.basic.dto;
+
+import org.testng.AssertJUnit;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import ch.systemsx.cisd.openbis.generic.shared.basic.PrimitiveValue;
+
+/**
+ * @author Piotr Buczek
+ */
+public class PrimitiveValueTest extends AssertJUnit
+{
+    private enum ExpectedResult
+    {
+        LOWER, EQUAL, HIGHER;
+    }
+
+    @DataProvider(name = "values")
+    protected Object[][] getValues()
+    {
+        return new Object[][]
+            {
+                /* NULL == NULL == "" */
+                { PrimitiveValue.NULL, PrimitiveValue.NULL, ExpectedResult.EQUAL },
+                { PrimitiveValue.NULL, new PrimitiveValue(""), ExpectedResult.EQUAL },
+                /* NULL < anything else */
+                { PrimitiveValue.NULL, new PrimitiveValue("text"), ExpectedResult.LOWER },
+                { PrimitiveValue.NULL, new PrimitiveValue("5"), ExpectedResult.LOWER },
+                { PrimitiveValue.NULL, new PrimitiveValue(-10L), ExpectedResult.LOWER },
+                { PrimitiveValue.NULL, new PrimitiveValue(0L), ExpectedResult.LOWER },
+                { PrimitiveValue.NULL, new PrimitiveValue(10L), ExpectedResult.LOWER },
+                { PrimitiveValue.NULL, new PrimitiveValue(-10.0), ExpectedResult.LOWER },
+                { PrimitiveValue.NULL, new PrimitiveValue(0.0), ExpectedResult.LOWER },
+                { PrimitiveValue.NULL, new PrimitiveValue(10.0), ExpectedResult.LOWER },
+                /* String < Number */
+                { new PrimitiveValue("text"), new PrimitiveValue(-10L), ExpectedResult.LOWER },
+                { new PrimitiveValue("text"), new PrimitiveValue(0L), ExpectedResult.LOWER },
+                { new PrimitiveValue("text"), new PrimitiveValue(10L), ExpectedResult.LOWER },
+                { new PrimitiveValue("text"), new PrimitiveValue(-10.0), ExpectedResult.LOWER },
+                { new PrimitiveValue("text"), new PrimitiveValue(0.0), ExpectedResult.LOWER },
+                { new PrimitiveValue("text"), new PrimitiveValue(10.0), ExpectedResult.LOWER },
+                /* String number < Number */
+                { new PrimitiveValue("5"), new PrimitiveValue(5L), ExpectedResult.LOWER },
+                { new PrimitiveValue("5"), new PrimitiveValue(-10L), ExpectedResult.LOWER },
+                { new PrimitiveValue("5"), new PrimitiveValue(0L), ExpectedResult.LOWER },
+                { new PrimitiveValue("5"), new PrimitiveValue(10L), ExpectedResult.LOWER },
+                { new PrimitiveValue("5"), new PrimitiveValue(-10.0), ExpectedResult.LOWER },
+                { new PrimitiveValue("5"), new PrimitiveValue(0.0), ExpectedResult.LOWER },
+                { new PrimitiveValue("5"), new PrimitiveValue(10.0), ExpectedResult.LOWER },
+                { new PrimitiveValue("5.0"), new PrimitiveValue(5.0), ExpectedResult.LOWER },
+                { new PrimitiveValue("5.0"), new PrimitiveValue(-10L), ExpectedResult.LOWER },
+                { new PrimitiveValue("5.0"), new PrimitiveValue(0L), ExpectedResult.LOWER },
+                { new PrimitiveValue("5.0"), new PrimitiveValue(10L), ExpectedResult.LOWER },
+                { new PrimitiveValue("5.0"), new PrimitiveValue(-10.0), ExpectedResult.LOWER },
+                { new PrimitiveValue("5.0"), new PrimitiveValue(0.0), ExpectedResult.LOWER },
+                { new PrimitiveValue("5.0"), new PrimitiveValue(10.0), ExpectedResult.LOWER },
+                /* String vs String */
+                { new PrimitiveValue("aba"), new PrimitiveValue("aba"), ExpectedResult.EQUAL },
+                { new PrimitiveValue("aba"), new PrimitiveValue("abc"), ExpectedResult.LOWER },
+                { new PrimitiveValue("abc"), new PrimitiveValue("abca"), ExpectedResult.LOWER },
+                { new PrimitiveValue("aba"), new PrimitiveValue("abca"), ExpectedResult.LOWER },
+                /* Long vs Long */
+                { new PrimitiveValue(10L), new PrimitiveValue(10L), ExpectedResult.EQUAL },
+                { new PrimitiveValue(-10L), new PrimitiveValue(0L), ExpectedResult.LOWER },
+                { new PrimitiveValue(-10L), new PrimitiveValue(10L), ExpectedResult.LOWER },
+                { new PrimitiveValue(5L), new PrimitiveValue(10L), ExpectedResult.LOWER },
+                /* Double vs Double */
+                { new PrimitiveValue(9.9), new PrimitiveValue(9.9), ExpectedResult.EQUAL },
+                { new PrimitiveValue(9.9), new PrimitiveValue(10.0), ExpectedResult.LOWER },
+                /* Long vs Double */
+                { new PrimitiveValue(0L), new PrimitiveValue(0.0), ExpectedResult.EQUAL },
+                { new PrimitiveValue(10L), new PrimitiveValue(10.0), ExpectedResult.EQUAL },
+                { new PrimitiveValue(-10L), new PrimitiveValue(-5.0), ExpectedResult.LOWER },
+                { new PrimitiveValue(9.9), new PrimitiveValue(10L), ExpectedResult.LOWER },
+
+            };
+    }
+
+    @Test(dataProvider = "values")
+    public void testComparison(PrimitiveValue v1, PrimitiveValue v2, ExpectedResult expectedResult)
+    {
+        switch (expectedResult)
+        {
+            case EQUAL:
+                assertTrue(v1.compareTo(v2) == 0);
+                assertTrue(v2.compareTo(v1) == 0);
+                break;
+            case LOWER:
+                assertTrue(v1.compareTo(v2) < 0);
+                assertTrue(v2.compareTo(v1) > 0);
+                break;
+            case HIGHER:
+                assertTrue(v1.compareTo(v2) > 0);
+                assertTrue(v2.compareTo(v1) < 0);
+                break;
+        }
+    }
+}