[corlib] Allow to use custom comparer when sorting null values.
[mono.git] / mcs / class / corlib / Test / System / ArrayTest.cs
index 71a21049911737b672aaa0b19f870bd3b902d8bf..eab4c40e1434ad47d8c4fb335497cb760a647a24 100644 (file)
@@ -2510,6 +2510,27 @@ public class ArrayTest
                }
        }
 
+       [Test]
+       public void Sort_NullValues ()
+       {
+               var s = new [] { "a", null, "b", null };
+               Array.Sort (s, (a, b) => {
+                       if (a == null) {
+                               return b == null ? 0 : 1;
+                       }
+
+                       if (b == null)
+                               return -1;
+
+                       return a.CompareTo (b);
+               });
+
+               Assert.AreEqual ("a", s [0], "#1");
+               Assert.AreEqual ("b", s [1], "#2");
+               Assert.IsNull (s [2], "#3");
+               Assert.IsNull (s [3], "#4");
+       }
+
        [Test] // #616416
        public void SortNonGenericDoubleItems () {
             double[] doubleValues = new double[11];