Show pageDiscussionOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ==== SORT ==== <callout type="primary" color="" icon="fa fa-book" title="Synopsis"> ---- Sort elements in a list </callout> <callout color="green" icon="fa fa-indent" title="Stack Diagram"> ---- ^ __Input Stack__ ^ ^ __Output Stack__ ^ | **L** | **→** | **L<sub>sorted</sub>** | | //Level 1// | //→// | //Level 1// | {{page>manual:chapter6:aux:legend&nofooter&noeditbtn&inline}} | **Keyword type** | [[manual:chapter5:basics#commands|Command]] || | **Parallel list processing capabilities** | [[manual:chapter5:listproc#group-2commands-that-must-use-dolist-to-parallel-process|Group 2]] | //Commands that must use //''[[manual:chapter6:lists:cmd_cmddolist|DOLIST]]''// to parallel process// | | **Affected by flags** | //None// || </callout> <callout color="orangered" icon="fa fa-comment" title="Description"> ---- The ''SORT'' command uses a variant of the [[https://en.wikipedia.org/wiki/Insertion_sort|Insertion Sort]] (namely, the **Binary Insertion Sort**) to order the elements of a list in ascending order.\\ \\ All the elements in the list must be of the same type; the comparison between elements is done by the ''[[manual:chapter6:operators:cmd_ovr_cmp|CMP]]'' operator: if the ''[[manual:chapter6:flags:cmd_type|TYPE]]'' of the objects within the list is not supported by ''[[manual:chapter6:operators:cmd_ovr_cmp|CMP]]'', no error is issued and the original list is left unmodified. </callout> <callout type="warning" icon="true" title="Compatibility"> ---- ''SORT'' is not fully equivalent to its **userRPL** counterpart. In particular: * in **newRPL** strings are not supported (yet). </callout> <callout type="info" icon="true" title="Usage"> ---- **__Input__** <code> 4: 3: 2: 1: { 5 1 4 3.1415 } ………………………………………………………………………………………………………… SORT </code> \\ **__Output__** <code> 4: 3: 2: 1: { 1 3.1415 4 5 } ………………………………………………………………………………………………………… </code> </callout> <callout color="darkgray" icon="fa fa-hand-o-right" title="Related Commands"> ---- {{page>manual:chapter6:lists&nofooter&noeditbtn&inline}} </callout> manual/chapter6/lists/cmd_sort.txt Last modified: 2021/10/03 14:50by jojo1973