diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-07-28 18:39:00 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-07-28 18:39:39 +0200 |
commit | 76cc8e97a2cf3265b39cb6c1b444c7926871f6a0 (patch) | |
tree | 0c9ce19079a3e29b1deaec35df0ce916136566ad /doc/manual/expressions/builtins.xml | |
parent | 50807f3dd5241667dac0c0cc302042d648de4b42 (diff) |
Add sort primop
Diffstat (limited to 'doc/manual/expressions/builtins.xml')
-rw-r--r-- | doc/manual/expressions/builtins.xml | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/doc/manual/expressions/builtins.xml b/doc/manual/expressions/builtins.xml index 446157056..6642513f6 100644 --- a/doc/manual/expressions/builtins.xml +++ b/doc/manual/expressions/builtins.xml @@ -779,6 +779,29 @@ builtins.replaceStrings ["oo" "a"] ["a" "i"] "foobar" </varlistentry> + <varlistentry><term><function>builtins.sort</function> + <replaceable>comparator</replaceable> <replaceable>list</replaceable></term> + + <listitem><para>Return <replaceable>list</replaceable> in sorted + order. It repeatedly calls the function + <replaceable>comparator</replaceable> with two elements. The + comparator should return <literal>true</literal> if the first + element is less than the second, and <literal>false</literal> + otherwise. For example, + +<programlisting> +builtins.sort builtins.lessThan [ 483 249 526 147 42 77 ] +</programlisting> + + produces the list <literal>[ 42 77 147 249 483 526 + ]</literal>.</para> + + <para>This is a stable sort: it preserves the relative order of + elements deemed equal by the comparator.</para></listitem> + + </varlistentry> + + <varlistentry><term><function>builtins.stringLength</function> <replaceable>e</replaceable></term> |