CSV sort
csv-sort · version 1.0.0 · CSV & tables · free, no key needed
Stably sort CSV rows by exact named string columns.
Use when you need to: csv sort · sort csv rows · sort csv ascending.
Supported
- csv sort
- sort csv rows
- sort csv ascending
- sort csv descending
- sort csv by columns
Not supported
- numeric sort
- locale sort
- natural sort
- fuzzy matching
- mixed sort directions
- read files
- fetch urls
Behavior
- key_columns names unique existing headers exactly; listed order determines multi-key precedence.
- Values are compared lexicographically by JavaScript UTF-16 code units without locale or numeric coercion.
- order is ascending by default and may be descending; equal keys retain input order in either direction.
- Header-only input is supported; an empty document is rejected because it has no header.
- The first header name may not begin with U+FEFF because it is ambiguous with a CSV byte-order mark.
Input
csv(string, required): max length 256000key_columns(array of string, required): min items 1; max items 256; each min length 1order(one of "ascending", "descending", optional): default"ascending"
Output
- string
Limits
- max input bytes: 256000
- max data rows: 5000
- max columns: 256
- max header name bytes: 256
- max key columns: 256
- max output bytes: 256000
Example
Request input:
{
"csv": "team,name\nb,Ada\na,Zoe\na,Ada\n",
"key_columns": [
"team",
"name"
]
}
Response:
{
"result": "team,name\na,Ada\na,Zoe\nb,Ada\n"
}
How to call it
MCP
Connect https://computefirst.net/mcp (setup), then call execute with:
{
"id": "csv-sort",
"version": "1.0.0",
"input": {
"csv": "team,name\nb,Ada\na,Zoe\na,Ada\n",
"key_columns": [
"team",
"name"
]
}
}
HTTP (no key)
curl -X POST https://computefirst.net/v1/tools/csv-sort/versions/1.0.0/execute \
-H "Content-Type: application/json" \
-d '{"csv":"team,name\nb,Ada\na,Zoe\na,Ada\n","key_columns":["team","name"]}'
The machine-readable contract is at /v1/tools/csv-sort/versions/1.0.0.
CLI
node cli.mjs run csv-sort 1.0.0 --input input.json --base-url https://computefirst.net
Get the client at /clients/cli/.
Related tools
- CSV dedupe: Remove duplicate CSV data rows while preserving the first occurrence.
- CSV group count: Count CSV rows by exact named-column tuples in first-seen order.
- CSV row diff: Compare two CSV documents with identical headers by unique key tuples and report added, removed, and changed rows.
- CSV split column: Split one CSV column on an exact separator into uniquely named columns.
- CSV transpose: Transpose a CSV matrix including the header row, then re-validate headers.
- CSV add row number: Prepend a 1-based row_number column of canonical integer strings.