github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/commands/msort.md (about) 1 # `msort` 2 3 > Sorts an array - data type agnostic 4 5 ## Description 6 7 This builtin takes input from stdin, sorts it and the outputs it to stdout. 8 9 The code behind `msort` is significantly more lightweight than UNIX sort. 10 It doesn't work with numeric types (eg sorting floating point numbers), 11 reversed order nor multi-column data. It is specifically designed to work 12 with lists of data. For example arrays in data formats like JSON (`json`), 13 YAML (`yaml`) or S-Expressions (`sexp`); or lists of strings (`str`). The 14 intention is to cover use cases not already covered by UNIX sort while also 15 providing something rudimentary for Murex scripts to function on Windows 16 without having to write lots of ugly platform-specific code. This is also 17 the reason this builtin is called `msort` rather than conflicting with the 18 existing UNIX name, `sort`. 19 20 ## Usage 21 22 ``` 23 <stdin> -> msort -> <stdout> 24 ``` 25 26 ## Examples 27 28 ``` 29 » tout json (["c", "b", "a"]) -> msort 30 [ 31 "a", 32 "b", 33 "c" 34 ] 35 ``` 36 37 Since `msort` does not support reversed order, you will need to pipe the 38 output of `msort` into another builtin: 39 40 ``` 41 » tout json (["c", "b", "a"]) -> msort -> mtac 42 [ 43 "c", 44 "b", 45 "a" 46 ] 47 ``` 48 49 ## Synonyms 50 51 * `msort` 52 * `list.sort` 53 54 55 ## See Also 56 57 * [`[ ..Range ]`](../parser/range.md): 58 Outputs a ranged subset of data from STDIN 59 * [`[ Index ]`](../parser/item-index.md): 60 Outputs an element from an array, map or table 61 * [`[[ Element ]]`](../parser/element.md): 62 Outputs an element from a nested structure 63 * [`a` (mkarray)](../commands/a.md): 64 A sophisticated yet simple way to build an array or list 65 * [`alter`](../commands/alter.md): 66 Change a value within a structured data-type and pass that change along the pipeline without altering the original source input 67 * [`append`](../commands/append.md): 68 Add data to the end of an array 69 * [`count`](../commands/count.md): 70 Count items in a map, list or array 71 * [`ja` (mkarray)](../commands/ja.md): 72 A sophisticated yet simply way to build a JSON array 73 * [`jsplit` ](../commands/jsplit.md): 74 Splits STDIN into a JSON array based on a regex parameter 75 * [`mtac`](../commands/mtac.md): 76 Reverse the order of an array 77 * [`prepend`](../commands/prepend.md): 78 Add data to the start of an array 79 80 <hr/> 81 82 This document was generated from [builtins/core/lists/msort_doc.yaml](https://github.com/lmorg/murex/blob/master/builtins/core/lists/msort_doc.yaml).