Escribal
Back to Docs

CSV / TSV

Sorting

This group reorders the rows of a loaded table — alphabetically, numerically or by date, ascending or descending, by one column or by two, or shuffled into a random order. These instructions change the loaded document in place: after they run, the rows of the table you keep working with are in the new order.

Prerequisite: a CSV/TSV document must already be loaded — created with Create CSV/TSV file or opened with one of the Reading instructions. These instructions read that loaded document and reorder its rows.

These concepts recur across the instructions in this group; they are explained here once.

  • Document: the Document key points to the loaded CSV/TSV these instructions reorder. If you leave it empty, the current document is used (the one instructions work on by default). If the key isn’t loaded, the instruction does nothing.

  • These reorder the loaded table in place. There is no output file — the rows are rearranged inside the document in memory, and later instructions see the new order. To write it to disk afterward, use a Saving & exporting instruction.

  • The sort order is detected automatically. For a column-based sort, the engine looks at the first non-blank value in the column and picks the ordering to match: numbers are ordered numerically, dates chronologically, and anything else as text (ignoring upper/lower case).

  • Columns are found by name, ignoring upper/lower case. A column name that doesn’t match any column leaves every row looking equal, so the order is left effectively unchanged.

  • Works with tables loaded with headers. Column-based sorts read the values by column name, so they need a table loaded with headers. Sort Randomly doesn’t look at any column, so it shuffles any table.

  • Save a result (saveCountKey): every instruction can save the number of rows in the table (unchanged by sorting) under the name you type, for later instructions to use with @name. Leave it empty and nothing is saved.

  • Dynamic values @name: the text fields (the column names) accept a saved value — type @ followed by its name and the engine substitutes it at run time.

  • “From variable” fields: the @name trick only works in text fields. So that a numeric field (like Random seed) or a yes/no field (like Primary ascending or Use seed) can also take its value from a saved value, each one has a companion “from variable” field:

    • If you leave it empty, the value typed in the normal field is used.
    • If you fill it in with the name of a saved value, the engine ignores the normal field and reads the value from that variable.

    This is mainly for chaining instructions. If you only work with fixed values, you can ignore it.

Sort Ascending .csv

Sorts the rows ascending (A→Z, smallest→largest, earliest→latest) by the values of one column.

When to use it: to put a table in order by a field — e.g. names A→Z, prices low→high, or dates oldest→newest.

Parameter Meaning Default Required
Column name The column to sort by (accepts @name) (empty) Yes
Document key The loaded CSV/TSV to reorder. Empty = current document (empty) No
Save count key Saves the number of rows in the table (empty) No

Important behavior: if Column name is empty (or the document isn’t loaded) nothing happens. The order (numeric, date or text) is auto-detected from the first non-blank value in the column.


Sort By Multiple Columns .csv

Sorts by a primary column, and breaks ties with a secondary column — each in its own ascending or descending direction.

When to use it: to sort by more than one field — e.g. by City first, then by Last name within each city.

Parameter Meaning Default Required
Document key The loaded CSV/TSV to reorder. Empty = current document (empty) No
Primary column The main column to sort by (accepts @name) (empty) Yes
Primary ascending If yes, the primary column sorts ascending; if no, descending yes No
Secondary column The tie-breaker column (accepts @name) (empty) No
Secondary ascending If yes, the secondary column sorts ascending; if no, descending yes No
Primary ascending (from variable) Reads the yes/no value from a saved value (empty) No
Secondary ascending (from variable) Reads the yes/no value from a saved value (empty) No
Save count key Saves the number of rows in the table (empty) No

Important behavior: if Primary column is empty (or the document isn’t loaded) nothing happens. The order of each column (numeric, date or text) is auto-detected independently. The secondary column is only used when Secondary column is filled in; left empty, rows are sorted by the primary column alone.


Sort Descending .csv

Sorts the rows descending (Z→A, largest→smallest, latest→earliest) by the values of one column.

When to use it: to put the highest or most recent rows first — e.g. prices high→low or dates newest→oldest.

Parameter Meaning Default Required
Column name The column to sort by (accepts @name) (empty) Yes
Document key The loaded CSV/TSV to reorder. Empty = current document (empty) No
Save count key Saves the number of rows in the table (empty) No

Important behavior: if Column name is empty (or the document isn’t loaded) nothing happens. The order (numeric, date or text) is auto-detected from the first non-blank value in the column.


Sort Randomly .csv

Shuffles the rows into a random order.

When to use it: to draw a random sample, or to remove any existing ordering — e.g. before splitting a table into random groups.

Parameter Meaning Default Required
Document key The loaded CSV/TSV to reorder. Empty = current document (empty) No
Use seed If yes, the shuffle uses the seed below and is repeatable; if no, it is different every run no No
Random seed The number that makes the shuffle repeatable (only used when Use seed is yes) 0 No
Use seed (from variable) Reads the yes/no value from a saved value (empty) No
Random seed (from variable) Reads the seed from a saved value (empty) No
Save count key Saves the number of rows in the table (empty) No

Important behavior: if the document isn’t loaded nothing happens; no column is needed, so it shuffles any table. Leave Use seed at no for a different shuffle every time — the seed is then ignored, whatever you typed in it. Turn Use seed to yes and any seed number (including 0, and negatives too) gives the same shuffle on every run — useful for reproducible samples.


This documentation is the help of the application, and it comes underCreative Commons Attribution 4.0.