[Nix-dev] patch list.nix fix sort

Marc Weber marco-oweber at gmx.de
Thu Feb 17 21:08:35 CET 2011


add missing ++ concat in quickfix sort in lists.nix

diff --git a/pkgs/lib/lists.nix b/pkgs/lib/lists.nix
index 36fa236..9957c48 100644
--- a/pkgs/lib/lists.nix
+++ b/pkgs/lib/lists.nix
@@ -157,7 +157,7 @@ rec {
         else let
           part = partition (strictLess (head l)) (tail l);
         in
-          qs part.wrong ([(head l)] ++ qs part.right []);
+          (qs part.wrong ([(head l)] ++ qs part.right [])) ++ concat;
     in
       qs list [];
 
diff --git a/pkgs/lib/tests.nix b/pkgs/lib/tests.nix
index cfd1a46..2f243a5 100644
--- a/pkgs/lib/tests.nix
+++ b/pkgs/lib/tests.nix
@@ -124,5 +124,18 @@ runTests {
     expr = mergeShellCode shells code;
     expected = { bash = "\na\nb\nB\nc\nd\n"; zsh = "\na\nz\nZ\nc\nd\n"; };
   };
+
+  testListSort = {
+    expr = all (eqStrict [1 2 3]) (map (sort builtins.lessThan)
+      [
+      [ 1 2 3 ]
+      [ 1 3 2 ]
+      [ 2 3 1 ]
+      [ 2 1 3 ]
+      [ 3 2 1 ]
+      [ 3 1 2 ]
+      ]);
+    expected = true;
+  };
   
 }

Marc Weber



More information about the nix-dev mailing list