aboutsummaryrefslogtreecommitdiff
path: root/test/arrays.tm
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-04-02 13:08:06 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-04-02 13:08:06 -0400
commitc73e96ff916209d74e2be9bd7d8de3758685ce4d (patch)
tree8f902fea5b6790061e48600243f0f8faeded32dd /test/arrays.tm
parentb6534ce34706d1a98584e5f916107d91da072346 (diff)
Add comparison operator <> and array method to sort by a custom
comparison function
Diffstat (limited to 'test/arrays.tm')
-rw-r--r--test/arrays.tm12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/arrays.tm b/test/arrays.tm
index e8856b3b..d4dd2119 100644
--- a/test/arrays.tm
+++ b/test/arrays.tm
@@ -73,3 +73,15 @@ if yes
>> arr := [10, 20, 30]
>> arr:reversed()
= [30, 20, 10]
+
+if yes
+ >> nums := [10, -20, 30]
+ >> nums:sort()
+ >> nums
+ = [-20, 10, 30]
+ >> nums:sort(func(x:&%Int,y:&%Int) x:abs() <> y:abs())
+ >> nums
+ = [10, -20, 30]
+ >> nums:sort(func(x:&%Int,y:&%Int) y[] <> x[])
+ >> nums
+ = [30, 10, -20]