File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -3674,6 +3674,32 @@ static RegisterPrimOp primop_sort({
3674
3674
3675
3675
This is a stable sort: it preserves the relative order of elements
3676
3676
deemed equal by the comparator.
3677
+
3678
+ *comparator* must impose a strict weak ordering on the set of values
3679
+ in the *list*. This means that for any elements *a*, *b* and *c* from the
3680
+ *list*, *comparator* must satisfy the following relations:
3681
+
3682
+ 1. Transitivity
3683
+
3684
+ ```nix
3685
+ comparator a b && comparator b c -> comparator a c
3686
+ ```
3687
+
3688
+ 1. Irreflexivity
3689
+
3690
+ ```nix
3691
+ comparator a a == false
3692
+ ```
3693
+
3694
+ 1. Transitivity of equivalence
3695
+
3696
+ ```nix
3697
+ let equiv = a: b: (!comparator a b && !comparator b a); in
3698
+ equiv a b && equiv b c -> equiv a c
3699
+ ```
3700
+
3701
+ If the *comparator* violates any of these properties, then `builtins.sort`
3702
+ reorders elements in an unspecified manner.
3677
3703
)" ,
3678
3704
.fun = prim_sort,
3679
3705
});
You can’t perform that action at this time.
0 commit comments