Numbers: sort
numbers_sortSort an Apple Numbers table's body rows by a chosen column while keeping header rows on top. If formulas reference other rows, use to_new_table=true to produce a sorted values copy.
Instructions
Sort a table's body rows by a column letter (header rows stay on top). Verified as a pure reorder. A table whose formulas read other rows (e.g. =B2*0.1 below a base-figure row) is refused, because Numbers' sort would break them; for it, to_new_table=true leaves the table, its formulas and its charts as they are and puts a sorted copy of its values (no formulas) in a new table on the same sheet (named new_table_name, default " sorted"). Chart the copy with keynote_build_deck. Needs macOS + Numbers, file closed. dry_run=true previews the change on a copy without touching the file. Use to reorder body rows by one column; header rows stay on top. If it refuses because formulas read other rows, call it again with to_new_table=true for a sorted copy; never rewrite the formulas to force it. Needs the Numbers app.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the .numbers file (absolute, or starting with ~). | |
| sheet | No | Sheet name. Omit when the file has one sheet (iwork_read lists sheets and tables). | |
| table | No | Table name on that sheet. Omit when the sheet has one table. | |
| column | Yes | Column letter to sort by, e.g. "C". | |
| dry_run | No | true = make the change on a throwaway copy, run every check, and return what would change; the file itself is not touched. Use it before broad or risky edits and show the user. | |
| descending | No | true = largest/last first. | |
| to_new_table | No | true = leave the table as it is and put a sorted copy of its values (no formulas) in a new table on the same sheet. Use it when the table's formulas read other rows. | |
| new_table_name | No | Name for the new table (with to_new_table); default "<table> sorted". |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||