From 95100469b6c7f301bb14bcda5dbc16b93c9ce0dc Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 2 Apr 2024 13:13:33 -0400 Subject: Add array:sorted() --- test/arrays.tm | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test') 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] -- cgit v1.2.3