0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

Use builtins.sort

This commit is contained in:
Eelco Dolstra 2015-07-28 18:42:04 +02:00
parent 5976d393fb
commit 395fdaef6c

View file

@ -176,7 +176,8 @@ rec {
# elements and returns true if the first argument is strictly below # elements and returns true if the first argument is strictly below
# the second argument. The returned list is sorted in an increasing # the second argument. The returned list is sorted in an increasing
# order. The implementation does a quick-sort. # order. The implementation does a quick-sort.
sort = strictLess: list: sort = builtins.sort or (
strictLess: list:
let let
len = length list; len = length list;
first = head list; first = head list;
@ -190,7 +191,7 @@ rec {
pivot = pivot' 1 { left = []; right = []; }; pivot = pivot' 1 { left = []; right = []; };
in in
if len < 2 then list if len < 2 then list
else (sort strictLess pivot.left) ++ [ first ] ++ (sort strictLess pivot.right); else (sort strictLess pivot.left) ++ [ first ] ++ (sort strictLess pivot.right));
# Return the first (at most) N elements of a list. # Return the first (at most) N elements of a list.