# Line Sorter API

> Line Sorter organizes text by sorting lines alphabetically in ascending or descending order with case-sensitive options.

**Endpoint:** `POST https://api.apiverve.com/v1/linesorter`  
**Category:** Text Processing  
**Cost:** 1 credit per call  
**Canonical page:** https://apiverve.com/marketplace/linesorter

## Overview

A line sorter API for putting lists in order without writing sort code. Send an array of text lines and get them back sorted, with control over direction and whether capital letters are treated differently from lowercase. Use it as a text sorter to sort any list alphabetically, A to Z or Z to A.

It suits cleaning up exported lists, alphabetizing names, tags, product titles or glossary terms, normalizing config and data files before diffing them, and sorting user-pasted lists in no-code tools and spreadsheets that lack a reliable alphabetical sort. By default the sort ignores case, so "apple", "Banana" and "cherry" come back in the order a reader expects.

The response returns the sorted lines, how many lines were sorted, and the order and case setting that were applied, so a workflow can confirm what it got. Every field is available on every plan, including the Free plan.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl -X POST "https://api.apiverve.com/v1/linesorter" \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"lines":["The quick brown fox jumps over the lazy dog","An apple a day keeps the doctor away","banana","Cherry blossoms bloom in spring","date"],"order":"asc","caseSensitive":false,"natural":true,"unique":true}'
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `lines` | array | Yes | Array of text lines to sort (max 10,000) |
| `order` | string | No | Sort order. default asc. One of: asc, desc |
| `caseSensitive` | boolean | No | Enable case-sensitive sorting. default false |
| `natural` | boolean | No | Natural (numeric-aware) order: runs of digits compare as numbers, so item2 sorts before item10. default false |
| `unique` | boolean | No | Remove duplicate lines before sorting (case-insensitive unless caseSensitive is true); the first spelling is kept. default false |

## Response fields

- `sorted` — array · Array of sorted text lines
- `lineCount` — number · Total number of lines sorted (after duplicates are removed when unique is true)
- `order` — string · Sort order that was applied
- `caseSensitive` — boolean · Whether the sort compared case exactly; when false, lines are compared case-insensitively

## Sample response

```json
{
  "status": "ok",
  "error": null,
  "data": {
    "sorted": [
      "An apple a day keeps the doctor away",
      "banana",
      "Cherry blossoms bloom in spring",
      "date",
      "The quick brown fox jumps over the lazy dog"
    ],
    "lineCount": 5,
    "order": "asc",
    "caseSensitive": false
  }
}
```

## Use cases

- **List Organization** — Sort and organize lists alphabetically for better readability and data management
- **Data Cleanup** — Clean up and alphabetize data files with customizable sorting options
- **Content Sorting** — Sort text content with case-sensitive or case-insensitive options
- **File Processing** — Process and organize large text files with up to 10,000 lines

## SDKs

- **npm** — `npm install @apiverve/linesorter` (https://www.npmjs.com/package/@apiverve/linesorter)
- **NuGet** — `dotnet add package APIVerve.API.LineSorter` (https://www.nuget.org/packages/APIVerve.API.LineSorter)
- **Source** — https://github.com/apiverve/linesorter-api

## More

- Full reference: https://docs.apiverve.com/ref/linesorter
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
