1
1
mirror of https://github.com/tweag/nickel.git synced 2024-10-06 08:07:37 +03:00

Fix array.sort in stdlib

This commit is contained in:
Mahmoud Mazouz 2022-08-05 17:05:23 +02:00
parent 15f6c85f05
commit 666d78d564
No known key found for this signature in database
GPG Key ID: 67ECE70BC8FF7F2F

View File

@ -260,13 +260,13 @@
For example:
```nickel
sort (fun x y => if x < y then `Less else if (x == y) then `Equal else `Greater) [ 4, 5, 1, 2 ] =>
sort (fun x y => if x < y then `Lesser else if (x == y) then `Equal else `Greater) [ 4, 5, 1, 2 ] =>
[ 1, 2, 4, 5 ]
```
"%m
= fun cmp l =>
let first = %head% l in
let parts = partition (fun x => (cmp x first == `Less)) (%tail% l) in
let parts = partition (fun x => (cmp x first == `Lesser)) (%tail% l) in
if %length% l <= 1 then
l
else