List Operations: The Complete Guide (2026)
Sort, dedupe, shuffle, prefix, suffix, reformat. Six operations cover ~95% of the list manipulation any analyst, developer, or content writer ever needs. The decision tree, the tool-by-tool guidance, and the workflow patterns that compound the savings.
The six operations
Every list-manipulation task in any workflow reduces to one or more of six operations:
- Sort — reorder by alphabetical, numeric, length, or random.
- Dedupe — remove duplicate lines, optionally case-insensitive, optionally trimmed.
- Shuffle — reorder randomly with a uniform distribution.
- Prefix / Suffix — wrap each line with arbitrary text on both sides.
- Reformat — convert between list shapes: line-per-item, comma-separated, JSON array, SQL IN clause.
- Filter — keep or remove lines matching a pattern.
Mastery of these six handles essentially every text list problem an analyst, developer, content writer, or operations person encounters. The rest of this post walks through each, with the tool to use and the gotchas to avoid.
1. Sort
Four sort orders cover the use cases:
- Alphabetical (A–Z or Z–A). The default. Use for names, words, identifiers.
- Numeric. Use for prices, IDs, counts. The trap: alphabetical sort treats "10" as less than "9". Always pick numeric sort for numbers.
- By length. Useful for finding the longest URL, the shortest password, the outlier item.
- Random. Same effect as shuffle. Use sort-random when the destination expects a one-shot reorder.
The non-obvious sort: case-sensitivity. Banana sorts before apple in case-sensitive ASCII order (uppercase letters come before lowercase). For human-readable lists, almost always use case-insensitive sort.
Use the Sort Lines tool for one-paste sort. For more on the four orders, see How to Sort Lines Alphabetically.
2. Dedupe
Three dedup variants cover most needs:
- Strict. Remove only exact-match duplicates.
- Case-insensitive. Treat
Appleandappleas the same line. - Whitespace-normalized. Treat
" alice "and"alice"as the same line by trimming before comparison.
Dedup also has a stability question. The convention: keep the first occurrence, drop later ones. This preserves the input order for the lines that survive, which is usually what you want.
Use the Remove Duplicates tool for one-paste dedup. For the deeper guide, see How to Remove Duplicate Lines.
3. Shuffle
Shuffle is sort-random with one critical detail: the algorithm. The standard for uniform random permutation is Fisher-Yates (also called the Knuth shuffle). It produces each of the n! orderings with equal probability in O(n) time.
The naive shuffle people sometimes write — sort by a random key, or repeatedly swap random pairs — produces non-uniform distributions. For small lists this rarely matters; for larger lists used in scientific or statistical contexts, it does.
Use cases for shuffle:
- Randomizing question order in a quiz.
- Distributing test data across folds for cross-validation.
- Picking a random subset (shuffle, then take the first N).
- Removing accidental ordering from a list (shuffle, then sort by the desired key).
Use the Shuffle Lines tool for Fisher-Yates shuffle in the browser. For the algorithm explainer, see How to Shuffle Lines (Fisher-Yates).
4. Prefix and Suffix
Adding the same text to the start or end of every line. Sounds trivial. The reason it has its own tool: hand-doing it for 50 lines is tedious; doing it consistently across thousands of lines is essentially mandatory for code-friendly outputs.
Five common patterns:
| Goal | Prefix | Suffix | Result example |
|---|---|---|---|
| HTML list | <li> | </li> | <li>item</li> |
| Markdown bullet | - | (empty) | - item |
| JSON string array | " | ", | "item", |
| SQL IN clause | ' | ', | 'item', |
| CSV row prefix | row, | (empty) | row,item |
The cleanup step: after a "JSON array" or "SQL IN clause" prefix/suffix pass, the very last line still has a trailing comma that needs to come off. The TextKit Prefix/Suffix tool offers a "no-trailing-separator" toggle that handles this automatically.
Use the Prefix & Suffix tool. For more on the patterns, see How to Add Prefix/Suffix to Each Line.
5. Reformat
Lists arrive in shapes that don't match what the destination expects. Six common reformats:
- Line-per-item ⇄ comma-separated string
- Line-per-item → JSON array
- Line-per-item → SQL IN clause
- Line-per-item → HTML
<ul> - Tab-separated → markdown table
- Comma-separated → line-per-item
Most of these are prefix/suffix combined with a wrapping operation (open the array, close the array). The Format List for SQL/JSON/HTML deep-dive covers each one with worked examples.
6. Filter
Keep or remove lines matching a pattern. Use cases:
- Keep only lines containing
errorfor a quick log triage. - Remove lines containing
internal-domain.comfrom an email list. - Keep only lines that look like URLs.
- Remove blank lines.
For simple substring filters, the Find & Replace tool with regex enabled handles this. For more complex filters, drop to grep, awk, or a Python one-liner.
The compound workflow
Most real list problems are two or three operations chained:
- "I have a list with duplicates and want it sorted alphabetically." Dedup, then sort.
- "I have a CSV column I need as a SQL IN clause." Extract column, dedup, prefix-suffix with single quotes, wrap in parentheses.
- "I have 100 names I need to randomize for a contest." Shuffle, take the first N.
- "I have a list of URLs and want to find the longest." Sort by length descending, take the first.
Each operation runs in the browser, takes one paste, produces output you can paste into the next operation. The compounding speed is the value.
The tools at a glance
| Operation | TextKit tool | Best for lists up to |
|---|---|---|
| Sort | Sort Lines | 1M lines |
| Dedupe | Remove Duplicates | 1M lines |
| Shuffle | Shuffle Lines | 500k lines |
| Prefix / Suffix | Prefix & Suffix | 1M lines |
| Filter | Find & Replace (regex) | 1M lines |
Past 1M lines, drop to command line. Within 1M, the browser is faster than launching anything else.
For the deeper dives on each operation: How to Sort Lines, How to Shuffle Lines, How to Add Prefix/Suffix, How to Remove Duplicate Lines, Format List for SQL/JSON/HTML.
Frequently asked questions
What's the difference between sort and shuffle?
Sort produces deterministic output — same input always produces same output. Shuffle produces random output — same input produces different output each run. Both reorder; the determinism is the only difference.
Why use a tool instead of Excel for list work?
Excel is slow to launch, slow to copy/paste large lists into, and requires a round-trip through worksheet cells. For lists of 50-50,000 items, browser tools are 10-100x faster than the spreadsheet round-trip.
What's the size limit for browser-based list tools?
Most browser tools handle up to 1 million lines without issue. Past that, the browser's text-area performance degrades. For lists larger than 1M, drop to a command-line tool (sort, awk, jq).
How do I preserve order while removing duplicates?
Use a stable dedup that keeps the first occurrence and drops later ones. Most browser dedup tools (including the TextKit version) do this by default — explicit unsorted dedup.
Can these tools handle multi-column data?
Single-line tools (sort, dedupe, shuffle, prefix/suffix) treat each line as a single item. For multi-column tab-separated data, they sort and dedupe by the entire row, not by a specific column. For column-aware operations, use Excel, jq, or awk.
Why is Fisher-Yates the standard shuffle algorithm?
Because it produces a uniformly random permutation in O(n) time, with each of the n! orderings equally likely. Naive shuffle algorithms (sort by random key, repeated swaps) produce non-uniform distributions that bias toward certain orderings.
Keep reading
Written by the TextKit team. We build the tools we write about — try the list operation tools used in this post.