-
Notifications
You must be signed in to change notification settings - Fork 10
Table manipulation
Giorgio Garofalo edited this page Mar 31, 2025
·
2 revisions
The .tablesort
function sorts a table based on the values of a specific column.
Parameter | Description | Accepts |
---|---|---|
column |
Index of the column, starting from 1. | 1 to number of columns. |
order |
Sorting order. |
ascending (default), descending
|
.tablesort {2} order:{descending}
| Name | Age | City |
|------|-----|------|
| John | 25 | NY |
| Lisa | 32 | LA |
| Mike | 19 | CHI |
Result:
| Name | Age | City | |------|-----|------| | Lisa | 32 | LA | | John | 25 | NY | | Mike | 19 | CHI |
Notes:
- Uses column values as sorting keys.
- Works with nested/generated tables (e.g., from
csv
).
The .tablefilter
function keeps or removes rows based on the values of a specific column.
Parameter | Description | Accepts |
---|---|---|
column |
Index of the column, starting from 1. | 1 to number of columns. |
filter |
Lambda that returns whether each row should be kept, with the value of its cell in the corresponding column as input. |
Dynamic →Boolean lambda
|
.tablefilter {2} {@lambda x: .x::isgreater {20}}
| Name | Age | City |
|------|-----|------|
| John | 25 | NY |
| Lisa | 32 | LA |
| Mike | 19 | CHI |
Result:
| Name | Age | City | |------|-----|------| | John | 25 | NY | | Lisa | 32 | LA |
The .tablecompute
function computes the cells in a column and appends the result to a new row.
Parameter | Description | Accepts |
---|---|---|
column |
Index of the column, starting from 1. | 1 to number of columns. |
compute |
Lambda that returns the computed value, with the collection of the cells in the column as input. |
Iterable →Dynamic lambda
|
See Iterable to learn more about available operations on collections.
Example:
.tablecompute {2} {@lambda x: .x::average::round}
| Name | Age | City |
|------|-----|------|
| John | 25 | NY |
| Lisa | 32 | LA |
| Mike | 19 | CHI |
Result:
| Name | Age | City | |------|-----|------| | John | 25 | NY | | Lisa | 32 | LA | | Mike | 19 | CHI | | | 25 | |
Multiple table operations can be chained. The order of the operations goes from inner to outer:
.tablecompute {2} {@lambda x: .x::average::round}
.tablesort {2}
| Name | Age | City |
|------|-----|------|
| John | 25 | NY |
| Lisa | 32 | LA |
| Mike | 19 | CHI |
Result:
| Name | Age | City | |------|-----|------| | Mike | 19 | CHI | | John | 25 | NY | | Lisa | 32 | LA | | | 25 | |
Table operations can affect not only plain Markdown tables, but also any kind of table including those loaded from CSV.
.tablesort {2} order:{descending}
.csv {people.csv}
- Figures
- Image size
- TeX formulas
- Table caption
- Decorative headings
- Alerts (quote types)
- Quotation source
- Page breaks
- Text symbols (text replacement)
- Syntax of a function call
- Declaring functions
- Dynamic typing
- Including other Quarkdown files
- Importing external libraries
- Localization
- Document metadata
- Theme
- Page format
- Page margin content
- Page counter
- Automatic page break
- Numbering
- Table of contents
- Stacks (row, column, grid)
- Container
- Align
- Float
- Clip
- Box
- Collapsible
- Whitespace
- Variables
- Optionality
- Math
- Conditional statements
- Loops
- Let
- Destructuring
- String manipulation
- Table manipulation: sorting, computing, and more
- Generators
- String
- Number
- Markdown content
- Boolean
- None
- Enumeration entry
- Iterable
- Dictionary
- Range
- Lambda
- Size(s)
- Color
- Dynamic
- Paper: abstract, definitions, theorems, and more