aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-04-02 13:13:33 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-04-02 13:13:33 -0400
commit95100469b6c7f301bb14bcda5dbc16b93c9ce0dc (patch)
treef84837f45fdc90b3070bd17583329a89450f6f44 /test
parentc73e96ff916209d74e2be9bd7d8de3758685ce4d (diff)
Add array:sorted()
Diffstat (limited to 'test')
-rw-r--r--test/arrays.tm7
1 files changed, 7 insertions, 0 deletions
diff --git a/test/arrays.tm b/test/arrays.tm
index d4dd2119..60bdc69a 100644
--- a/test/arrays.tm
+++ b/test/arrays.tm
@@ -76,9 +76,16 @@ if yes
if yes
>> nums := [10, -20, 30]
+ // Sorted function doesn't mutate original:
+ >> nums:sorted()
+ = [-20, 10, 30]
+ >> nums
+ = [10, -20, 30]
+ // Sort function does mutate in place:
>> nums:sort()
>> nums
= [-20, 10, 30]
+ // Custom sort functions:
>> nums:sort(func(x:&%Int,y:&%Int) x:abs() <> y:abs())
>> nums
= [10, -20, 30]