Skip to content
PithLab

↑↓ to move · Enter to open · Esc to close

Sort Lines API

Sort lines alphabetically, naturally (1, 2, 10), by length, or shuffle them, with options to reverse, de-duplicate and drop blank lines.

POST /api/v1/tools/sort-linesMCP sort_linesText & Writing

Sort lines of text A–Z or Z–A, in natural number order, or by length, or shuffle them randomly. Optionally remove duplicates and blank lines as you sort.

Input

Send these as a JSON object. Unknown fields are rejected.

input
The text, one item per line. (string, required)
mode
alphabetical, natural (numbers in order), length, or shuffle (random order, different every call). (string, one of alphabetical, natural, length, shuffle, default "alphabetical")
reverse
Reverse the sorted order (Z–A, longest first). Ignored when shuffling. (boolean, default false)
unique
Drop repeated lines, keeping the first. (boolean, default false)
caseSensitive
Distinguish upper and lower case when comparing and de-duplicating. (boolean, default false)
removeBlank
Drop empty and whitespace-only lines. (boolean, default false)
locale
BCP 47 locale for alphabetical comparison, e.g. en, de, sv. (string, up to 35 characters, default "en")
curl https://pithlab.com/api/v1/tools/sort-lines \n  -H "Authorization: Bearer $PITHLAB_KEY" \n  -H "Content-Type: application/json" \n  -d '{"input":"file10.txt\nfile2.txt\nfile1.txt","mode":"natural"}'
Example response
{
  "ok": true,
  "result": {
    "output": "file1.txt\nfile2.txt\nfile10.txt",
    "lines": 3
  }
}