Text Sorter

Alphabetize text lists, logs, and tags or apply natural numeric sorting instantly.

How to Sort Text Online

1

Paste Text Lines

Paste any text payload containing multiple lines into the input editor. The sorter parses lines instantly.

2

Configure Sorting

Select order direction, natural numeric ordering, and case sensitivity through the master toolbar.

3

Copy Result

The text is automatically sorted in real time. Click Copy to export the result.

Tool Options

Order Direction Options

Sort items alphabetically ascending (A to Z) or reverse alphabetical order descending (Z to A).

Natural Collation Ordering

Applies localized collation matching to treat numbers logically (e.g. 2 sorted before 10 instead of alphabetically).

100% Client-Side Privacy

Runs entirely inside your browser memory, keeping your proprietary source code, secrets, and documents private.

Your Data Privacy

Web Tool
Privacy-First Architecture
Most of our web tools process your data entirely in-browser. Where server processing is technically required, payloads are evaluated statelessly in-memory and are never stored, saved, or logged.
REST API
Stateless In-Memory Processing
When you use our API endpoints, your requests are processed strictly in-memory without persistent database storage, disk logging, or data retention.
Want to learn more about how we safeguard your information and infrastructure?
Read our full Privacy Policy for detailed security standards, data retention principles, and compliance guarantees.

What does the Text Sorter do?

The Text Sorter arranges multiline text lists, log entries, CSV rows, and code elements according to alphabetical order (A–Z or Z–A), natural numeric sequence (e.g. 2 before 10), case sensitivity settings, and optional duplicate line removal.

Core Concepts

Understanding text line sorting algorithms and collation rules:

  • Alphabetical Collation: Orders lines based on standard unicode lexical values (ascending A–Z or descending Z–A).
  • Natural Numeric Sorting: Evaluates numerical digits inline using integer values (sorting file2.txt before file10.txt).
  • Case Sensitivity Controls: Distinguishes between uppercase and lowercase letters (Apple vs apple) or performs case-insensitive collation.
  • Concurrent Deduplication: Filters out redundant duplicate lines during the sort operation.

How to use the tool?

  1. Enter Text Lines: Enter or paste your multiline text or log output into the editor or click Load Sample.
  2. Configure Sort Options:
    • Choose your Order direction (Ascending or Descending).
    • Toggle Case-Sensitive, Natural Numeric Sorting, or Remove Duplicates.
  3. Sort & Copy: Click Sort Text Lines, then click Copy or Download to save your sorted text.

Related Developer Utilities

If you work with text processing, line formatting, and deduplication, explore these complementary tools:

REST API Integration

Blueutils provides a free REST API endpoint (POST https://blueutils.com/api/text/text-sorter) to programmatically sort multiline text list elements based on configurable sorting directions and collation strategies.

API Request Parameters

Name Type Description Example
rawText String Multiline text block to sort. "Pear\nApple\nOrange"
direction String Sort direction: "asc" or "desc". Default: "asc". "asc"
caseSensitive Boolean True to distinguish uppercase/lowercase. Default: false. false
numericNatural Boolean True for natural math ordering (2 before 10). Default: true. true
removeDuplicates Boolean True to strip duplicate lines. Default: false. false

API Request Payload Examples

cURL

curl -X POST https://blueutils.com/api/text/text-sorter \
  -H "Content-Type: application/json" \
  -d '{
    "rawText": "Pear\n10 apples\nApple\n2 apples",
    "direction": "asc",
    "caseSensitive": false,
    "numericNatural": true,
    "removeDuplicates": true
  }'

Python

import requests

url = "https://blueutils.com/api/text/text-sorter"
payload = {
    "rawText": "Pear\n10 apples\nApple\n2 apples",
    "direction": "asc",
    "caseSensitive": False,
    "numericNatural": True,
    "removeDuplicates": True
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())

Java

import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
    public static void main(String[] args) throws Exception {
        String jsonPayload = """
            {
                "rawText": "Pear\\n10 apples\\nApple\\n2 apples",
                "direction": "asc",
                "numericNatural": true,
                "removeDuplicates": true
            }
            """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://blueutils.com/api/text/text-sorter"))
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
            .build();

        HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.body());
    }
}

API Response Parameters

Name Type Description Example
isValid Boolean Indicates whether sorting completed successfully. true
result String Collation-sorted output text lines. "2 apples\n10 apples\nApple\nPear"

API Response Payload Examples

Success Response (HTTP 200 OK)

{
  "isValid": true,
  "result": "2 apples\n10 apples\nApple\nPear"
}

Validation Failure Response (HTTP 400 Bad Request)

{
  "isValid": false,
  "error": "Input text payload must be a string."
}

Rate Limit Exceeded Response (HTTP 429 Too Many Requests)

{
  "error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}

Why use an API to sort text?

Integrating the Text Sorter API into data cleaning pipelines, log analyzers, or AI agent tool calling provides essential advantages:

  • Rapid Script Validation: Normalizes messy output lists, environment variables, and log extracts into predictable ordered sequences.
  • Optimized Token Efficiency for AI Agents: LLMs frequently introduce subtle collation errors and misplace numbers when sorting lists. Invoking the API sorts thousands of lines deterministically without token hallucinations.
  • Deterministic Accuracy Without Hallucinations: Ensures 100% accurate natural numeric evaluation and unicode-compliant sorting.

Native Usage

How to sort text lists locally in terminal environments or scripts:

Windows (CMD / PowerShell)

# Sort text lines in PowerShell
Get-Content input.txt | Sort-Object | Set-Content sorted.txt

Linux / Unix (Bash)

# Sort text lines alphabetically in Linux
sort input.txt > sorted.txt

# Sort text lines with natural version/number sorting
sort -V input.txt > sorted.txt

Python

Using Python sorted:

with open("input.txt", "r", encoding="utf-8") as f:
    lines = f.readlines()

sorted_lines = sorted(lines, key=lambda s: s.strip().lower())

with open("sorted.txt", "w", encoding="utf-8") as f:
    f.writelines(sorted_lines)

print("Text sorted successfully.")

Java

Using Java Collections.sort:

import java.nio.file.*;
import java.util.*;

public class TextSorterExample {
    public static void main(String[] args) throws Exception {
        List<String> lines = Files.readAllLines(Paths.get("input.txt"));
        Collections.sort(lines, String.CASE_INSENSITIVE_ORDER);
        Files.write(Paths.get("sorted.txt"), lines);
        System.out.println("Text sorted successfully.");
    }
}

Frequently Asked Questions (FAQ)

How do I sort a list of text online?

Paste your text into the editor. The tool automatically sorts your lines alphabetically (A-Z) by default. You can change the order to descending (Z-A) using the toolbar.

Can I remove duplicate lines while sorting?

Yes. Check the Remove Duplicates option in the toolbar, and the sorter will automatically strip identical lines while ordering the remaining text.

What is Natural Numeric Sorting?

Natural numeric sorting treats multi-digit numbers logically. For example, File 2 will be sorted before File 10, whereas standard alphabetical sorting would incorrectly place File 10 before File 2.

Does the sorter handle case sensitivity?

By default, sorting is case-insensitive to group similar words together naturally. You can enable Case-Sensitive mode to strictly separate uppercase and lowercase letters.

Is my text data secure?

Yes. All sorting algorithms run 100% client-side directly within your browser. Your lists, logs, and sensitive data are never transmitted to external servers.

Rate Limits

UI Limits
100 uses per 15 minutes
Max payload size: 5 MB
API Limits
5 requests per 60 minutes
Max payload size: 256 KB
Need higher API rate limits, increased payload sizes, or custom developer solutions?
Contact our engineering team at support@blueutils.com for custom rate limit increases, higher quota allocations, or tailored enterprise integrations.