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/builtin/testscript | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/function/builtin/testscript') diff --git a/tests/function/builtin/testscript b/tests/function/builtin/testscript index 3d31ca2..3853ec2 100644 --- a/tests/function/builtin/testscript +++ b/tests/function/builtin/testscript @@ -77,6 +77,16 @@ $* <'print $type($identity(abc))' >'' : untyped } +: sort +: +{ + $* <'print $sort( d/t{a} t{c b} d/t{a})' >'t{b} t{c} d/t{a} d/t{a}' : name-basics + $* <'print $sort( d/t{a} t{c b} d/t{a}, dedup)' >'t{b} t{c} d/t{a}' : name-dedup + + $* <'print $sort([uint64s] 0 2 1 000)' >'0 0 1 2' : int-basics + $* <'print $sort([uint64s] 0 2 1 000, dedup)' >'0 1 2' : int-dedup +} + : getenv : { -- cgit v1.1