==== SORT ==== ---- Sort elements in a list ---- ^ __Input Stack__ ^ ^ __Output Stack__ ^ | **L** | **→** | **Lsorted** | | //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// || ---- 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. ---- ''SORT'' is not fully equivalent to its **userRPL** counterpart. In particular: * in **newRPL** strings are not supported (yet). ---- **__Input__** 4: 3: 2: 1: { 5 1 4 3.1415 } ………………………………………………………………………………………………………… SORT \\ **__Output__** 4: 3: 2: 1: { 1 3.1415 4 5 } ………………………………………………………………………………………………………… ---- {{page>manual:chapter6:lists&nofooter&noeditbtn&inline}}