From f500b3274b4c937d315a652aad3bfcdd808b49ec Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 2 Nov 2021 15:18:05 +0200 Subject: Add $sort() function Available overloads: $sort( [, ]) $sort( [, ]) $sort( [, ]) $sort( [, ]) $sort( [, ]) The following flag is supported by the all overloads: dedup - in addition to sorting also remove duplicates Additionally, the strings overload also support the following flag: icase - sort ignoring case Note that on case-insensitive filesystem the paths and dir_paths overload's order is case-insensitive. --- tests/function/path/testscript | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tests/function/path/testscript') diff --git a/tests/function/path/testscript b/tests/function/path/testscript index ad76513..a408ba4 100644 --- a/tests/function/path/testscript +++ b/tests/function/path/testscript @@ -3,7 +3,8 @@ .include ../../common.testscript -posix = ($cxx.target.class != 'windows') +windows = ($cxx.target.class == 'windows') +posix = (!$windows) s = ($posix ? '/' : '\') @@ -104,6 +105,20 @@ if! $posix EOO } +: sort +: +{ + $* <'print $sort([paths] a c b a)' >'a a b c' : basics + $* <'print $sort([paths] a c b a, dedup)' >'a b c' : dedup + + : icase + : + if $windows + { + $* <'print $sort([paths] a C B a)' >'a a B c' + } +} + : invalid-path : p = ($posix ? /../foo : 'c:/../foo'); -- cgit v1.1