Document Workflow
Sort unique lines naturally before an import
Deduplicate one-item-per-line data, apply locale-aware numeric sorting only when order is non-semantic, and verify counts and line endings before importing.
Written and tested by SimpleWebUtilsPublished: Reviewed:
How this workflow was checked
The review loaded the unmodified “Sort an import allowlist naturally” sample into Remove Duplicate Lines. We exercised the path from “Confirm that order is non-semantic” to “Enable sorting after deduplication”, checked the displayed or downloaded result against the example, and separately examined “Sorting before deciding duplicate rules” and “Alphabetizing precedence-sensitive configuration”.
Natural, case-insensitive sorting placed alpha, Beta, item2, and item10 in the expected order while the separately chosen duplicate rule removed only the repeated beta host. A destination dry run remained required because Intl.Collator ordering is not guaranteed to match a database or shell bytewise sort.
Problem
A copied import list can contain blank rows, repeats, inconsistent case, numeric suffixes, and mixed line endings. Sorting too early hides the first occurrence, while bytewise or spreadsheet sorting may produce a different order from the destination.
When to use this
- A list of hostnames, tags, labels, names, or IDs needs a predictable review order before import.
- Numeric suffixes such as item2 and item10 should appear in human-friendly order.
- Repeated rows should be collapsed before comparing two exports.
- The destination does not assign meaning to chronology, priority, or source order.
- You need a downloadable text result with explicit locale and line-ending behavior.
Steps
- Step 1
Confirm that order is non-semantic
Do not sort logs, migration steps, ACL precedence rules, playlists, or ranked lists unless the destination explicitly ignores order.
- Step 2
Preserve an unsorted source copy
Keep the original block so you can locate the first occurrence and recover chronology if an import review exposes a problem.
- Step 3
Clean blank rows deliberately
Remove blank lines separately when they are not valid values. Duplicate removal otherwise keeps one blank comparison value.
- Step 4
Set duplicate comparison rules
Choose exact case and optional trimmed comparison based on destination semantics, not on how similar rows look on screen.
- Step 5
Enable sorting after deduplication
The tool collapses duplicates first, then applies locale-aware natural sorting with numeric order, so item2 precedes item10.
- Step 6
Review ties and line endings
Equal sort keys retain source order. Mixed LF, CRLF, and CR input is normalized to the predominant style shown in the result notice.
- Step 7
Count, export, and dry-run the import
Compare expected and actual unique-line counts, download the exact text, and test a reversible or preview import before replacing production data.
Example
Sort an import allowlist naturally
Input
item10.example.com
Beta.example.com
item2.example.com
alpha.example.com
beta.example.comOutput
Case-insensitive with sorting on:
alpha.example.com
Beta.example.com
item2.example.com
item10.example.comCommon mistakes
Sorting before deciding duplicate rules
Case and whitespace policy determines which rows survive. Decide that first so sorting does not distract from an unintended merge.
Treating natural sort as bytewise order
Intl.Collator uses locale and numeric behavior. A database, shell sort, or target application can order the same text differently.
Alphabetizing precedence-sensitive configuration
Firewall rules, routing rules, CSS declarations, and migration steps can change behavior when reordered.
Using case conversion as deduplication
Changing all text to one case rewrites values. Case-insensitive comparison can merge variants while preserving the first original spelling.
Skipping a destination dry run
A clean-looking list can still violate uniqueness, encoding, or ordering rules in the receiving system. Validate before a destructive import.
FAQ
Is the output a strict A-to-Z byte sort?
No. It uses Intl.Collator for the page locale with numeric ordering, making it suitable for human review rather than binary reproducibility.
Why does item2 come before item10?
Numeric collation compares digit sequences as numbers instead of comparing each digit as plain text.
What happens when two kept lines have equal sort keys?
Their original source order breaks the tie, which makes repeated runs stable for the same browser locale and input.
Should I sort before or after removing duplicates?
Remove duplicates first. The tool does this automatically so sorting only arranges the final kept lines.
Can I use this for a Git-tracked file?
Yes when order is not meaningful, but inspect the line-ending notice and review the diff before committing because mixed endings may be normalized.
Does the sorter change capitalization or trim the result?
No. Comparison options affect keys, while the first original line remains the displayed value. Sorting changes only row order.