# Line Deduplicator, Sorter & Shuffler (`hipersoft/line-dedup-sort`) Actor

Clean big text and list files: remove duplicate lines, sort alphabetically or numerically, reverse, shuffle and trim blanks — handles lists too large for a desktop editor.

- **URL**: https://apify.com/hipersoft/line-dedup-sort.md
- **Developed by:** [hiper soft](https://apify.com/hipersoft) (community)
- **Categories:** Developer tools, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.0025 / list processed

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Line Deduplicator, Sorter & Shuffler

**Clean big text and list files in one run** — remove duplicate lines, sort, reverse, shuffle, trim whitespace and drop blank lines. Handles keyword lists, URL lists and wordlists far too large for a desktop text editor, and returns a ready-to-download cleaned file.

![Line Deduplicator, Sorter & Shuffler input — configure the options in the Apify Console](https://api.apify.com/v2/key-value-stores/SUfvnaFLd9z9eBCtV/records/line-dedup-sort-input.png)

### What it does

- **Deduplicate** lines (optionally case-insensitive).
- **Sort** A→Z, Z→A, natural (numbers-aware), reverse, or **shuffle**.
- **Trim** whitespace and **remove blank lines**.
- Returns counts (in/out, duplicates, blanks) + the cleaned file.

### Use cases

- **SEO / PPC** — dedupe and sort huge keyword lists.
- **Data cleaning** — tidy URL lists and exports before import.
- **Security / research** — process large wordlists that choke local editors.

### Input

Paste text, or point to a file URL.

```json
{ "text": "banana\napple\nApple\ncherry\nbanana", "dedupe": true, "caseInsensitiveDedupe": false, "trim": true, "removeBlankLines": true, "sort": "asc" }
```

| Field | Type | Description |
|---|---|---|
| `text` | string | Lines to process (one per line). |
| `fileUrl` | string | Optional link to a .txt/.csv file instead of pasting. |
| `dedupe` | boolean | Remove duplicate lines. Default `true`. |
| `caseInsensitiveDedupe` | boolean | Treat case-different lines as duplicates. |
| `trim` | boolean | Strip leading/trailing spaces. Default `true`. |
| `removeBlankLines` | boolean | Drop empty lines. Default `true`. |
| `sort` | string | `none`, `asc`, `desc`, `natural`, `reverse`, `shuffle`. |

### Output

![Line Deduplicator, Sorter & Shuffler output — the results as a clean dataset](https://api.apify.com/v2/key-value-stores/SUfvnaFLd9z9eBCtV/records/line-dedup-sort-output.png)

A summary row, plus the cleaned file at `result.txt` in your key-value store.

```json
{ "linesIn": 5, "linesOut": 3, "duplicatesRemoved": 1, "blanksRemoved": 0, "resultUrl": "https://api.apify.com/v2/key-value-stores/.../records/result.txt" }
```

#### Output schema

| Field | Type | Description |
|---|---|---|
| `linesIn` | integer | Lines in the input. |
| `linesOut` | integer | Lines after processing. |
| `duplicatesRemoved` | integer | Duplicate lines removed. |
| `blanksRemoved` | integer | Blank lines removed. |
| `resultUrl` | string (URL) | Link to the cleaned text file. |

### FAQ

**How big a list can it handle?** Very large — it streams the file into memory and processes in one pass.

**Can I automate it?** Yes — via [integrations on the Apify platform](https://apify.com/integrations) and the [Apify API](https://docs.apify.com/api/v2).

### Notes

Original clean-room implementation.

# Actor input Schema

## `text` (type: `string`):

Paste your lines here (one item per line). Leave empty if you provide a file URL instead.

## `fileUrl` (type: `string`):

Optional: a link to a .txt/.csv file to process instead of pasting text.

## `dedupe` (type: `boolean`):

Keep only the first occurrence of each line.

## `caseInsensitiveDedupe` (type: `boolean`):

Treat lines that differ only in letter case as duplicates.

## `trim` (type: `boolean`):

Strip leading/trailing spaces from each line.

## `removeBlankLines` (type: `boolean`):

Drop empty lines.

## `sort` (type: `string`):

How to order the output lines.

## Actor input object example

```json
{
  "text": "banana\napple\nApple\ncherry\n\nbanana\n  apple  ",
  "dedupe": true,
  "caseInsensitiveDedupe": false,
  "trim": true,
  "removeBlankLines": true,
  "sort": "none"
}
```

# Actor output Schema

## `results` (type: `string`):

The results as dataset items.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "text": `banana
apple
Apple
cherry

banana
  apple`
};

// Run the Actor and wait for it to finish
const run = await client.actor("hipersoft/line-dedup-sort").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "text": """banana
apple
Apple
cherry

banana
  apple  """ }

# Run the Actor and wait for it to finish
run = client.actor("hipersoft/line-dedup-sort").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "text": "banana\\napple\\nApple\\ncherry\\n\\nbanana\\n  apple  "
}' |
apify call hipersoft/line-dedup-sort --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,hipersoft/line-dedup-sort"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/wZXhS9PNggSe6sxa7/builds/4hzt5kiIOXDpUBC8W/openapi.json
