Text Sorter
Items {{ sortedLines.length }} Unique {{ uniqueCount }} Mode {{ sortModes[sort_mode] }} Locale {{ localeDisplay }} In {{ sepOptions[normalizeSepKey(input_sep)] }} Out {{ sepOptions[normalizeSepKey(output_sep)] }}
Text
Now: {{ localeDisplay }}
{{ filter_regex_error }}
MetricValueCopy
{{ r.label }} {{ r.value }}
MetricValueCopy
{{ r.label }} {{ r.value }}

          
:

Introduction:

Text lists are collections of lines that become clearer and more reusable when arranged with consistent rules and tidy spacing. Many tasks benefit from a natural sort for text lines that treats embedded numbers as numbers so names like photo2 and photo10 fall in human order.

You provide the lines and choose how to compare them, then you decide whether to keep case distinctions or fold them for a simpler view. Results can include line numbers, added prefixes or suffixes, and a chosen separator so you can paste the output where it is needed next.

Cleaning options remove blank lines, trim stray spaces, and collapse runs inside each item. You can ignore a, an, or the at the start when ordering titles so common articles do not push important words out of view.

Filtering narrows the list to matches or excludes unwanted items using plain text or patterns. A seeded shuffle gives a repeatable draw that you can recreate by sharing the same seed with teammates.

For a quick example, paste filenames such as File1, File10, and File2, pick natural order, and the items come back as File1 then File2 then File10. Add numbers and a comma separator to create a copy ready list for the next step.

Technical Details:

The content being measured is the order relationship between strings, with optional treatment of embedded digit runs as numeric values. The computation transforms your input into a processed list, applies filters, orders items with the selected comparison, removes repeats when requested, and emits a joined string together with simple counts. Natural ordering compares number sequences by value, while alphabetical ordering compares character by character with locale aware rules.

Results include the sorted items, totals, unique counts after processing, and averages that help spot unusual entries such as very long or empty lines. Comparability across runs improves when you keep the same locale, case policy, separators, and filter settings. Shuffle mode can be deterministic with a seed so the same inputs and seed recreate the same order.

Locale aware comparisons are performed with string collators both in standard and numeric modes, falling back to the default locale if the supplied tag is not valid. Seeded shuffling uses a Fisher–Yates style pass driven by a Mulberry32 pseudo‑random generator seeded from a 32‑bit FNV‑1a hash of your seed text.

Processing pipeline

  1. Split the source text by the chosen input separator.
  2. Normalize lines: optional trim and internal whitespace collapse.
  3. Strip ordered‑list numbers and ignore blank lines if requested.
  4. Apply include and exclude filters, then optional regex match.
  5. Compare items using alphabetical or natural ordering with locale.
  6. Reverse, length sort, or shuffle as selected.
  7. Remove duplicates after processing when enabled.
  8. Optionally prepend line numbers and add prefixes or suffixes.
  9. Join with the chosen output separator and newline style.
Symbols and data types
Symbol Meaning Unit/Datatype Source
L Input lines split by the selected separator string[] Input
L′ Preprocessed lines after trim, collapse, and stripping string[] Derived
F Filter predicates (include, exclude, optional regex) boolean per line Input
S Comparator (alphabetical, natural, reverse, length, shuffle) ordering rule Input
J Joiner built from output separator and newline style string Input
O Final output after optional numbering and affixes string Derived
Worked example
L = { File10 ,   File2 ,   File1 }
Natural A–Z { File1 ,   File2 ,   File10 }
Alphabetical A–Z { File1 ,   File10 ,   File2 }
Interpretation: natural order uses digit values inside names so humans read the sequence as one, two, ten.
Validation and bounds extracted from the code
Field Type Min Max Step/Pattern Error Text Placeholder
Text textarea Splits by newline, comma, semicolon, space, or tab Paste lines…
Upload file file Accepts .txt, .csv, text/plain; newlines normalized
Locale text Optional BCP‑47 tag; blank uses default auto
Sort mode select Alphabetical A–Z/Z–A, Natural A–Z/Z–A, Length, Reverse, Shuffle
Regex filter text Flags allowed: g i m s u y Invalid regex
Newline style select LF, CRLF, or CR applied when joining with newline
Shuffle seed text Seed hashed to 32‑bit for deterministic order optional seed

I/O formats & encoding

  • Input: pasted text or a .txt/.csv file; carriage returns normalize to line feeds on read.
  • Split policy: by selected token family; natural newlines respected after normalization.
  • Output: items joined by the chosen separator; newline style applies only when joining with newlines.
  • Exports: counts and stats assembled from computed values; JSON view shows inputs, counts, and array output.

Randomness, seeds & reproducibility

  • Sampling is without replacement using a Fisher–Yates pass.
  • Seed text is hashed with FNV‑1a to a 32‑bit integer.
  • Mulberry32 PRNG drives the shuffle; identical inputs and seed reproduce the same order.
  • Unsuitable for gambling or security decisions.

Networking & storage behavior

Processing runs entirely in the browser; files are read locally and newlines are normalized on load. No network requests are required to compute results.

Performance & complexity

  • Sorting: O(n log n) for ordered modes; de‑duplication: O(n) with a set.
  • Counts and stats traverse items once; memory holds one copy of the working array.

Diagnostics & determinism

  • Stats and counts expose totals, averages, and extremes for quick validity checks.
  • Seeded shuffle and fixed settings support fully reproducible runs.

Security considerations

  • Regex is user supplied; overly complex patterns may slow filtering.
  • No secrets are required and nothing is transmitted to a server.

Assumptions & limitations

  • Locale affects tie‑breaking and letter order across languages.
  • Natural order treats digit runs as numbers but not decimals inside words.
  • Ignoring articles applies only at the start of a line.
  • De‑duplication occurs after preprocessing and filtering.
  • Line numbering width matches the digits in the final item count.
  • Newline style applies only when using newline as the joiner.
  • Length sort breaks ties with alphabetical comparison.
  • Regex filters include matches; non‑matches are dropped.
  • Heads‑up Different environments may interpret locale tags differently.

Edge cases & error sources

  • Mixed encodings or stray control characters in pasted text.
  • Unicode normalization differences across sources.
  • Grapheme clusters where a visible character spans multiple code points.
  • Locale rules that handle accents differently than expected.
  • Empty lines that survive when trimming is off.
  • Numbers with leading zeros affecting natural comparisons.
  • Regex patterns that backtrack heavily and slow filtering.
  • Very long items that inflate averages and extremes.
  • Whitespace‑only items when collapse or trim is not enabled.
  • Global regex flags affecting repeated tests.

Privacy & compliance: Files are processed locally; nothing is uploaded. Outcomes are purely random and have no monetary value.

How‑to · Step‑by‑Step Guide

Text line ordering with optional cleanup and filters produces a tidy, reusable list.

  1. Paste your lines or load a text file.
  2. Select a sort mode Alphabetical/Natural/Length/Reverse/Shuffle.
  3. Set locale if you need specific language rules.
  4. Enable cleanup: trim, collapse spaces, ignore blanks, strip list numbers.
  5. Choose filters or a regex pattern and flags when needed.
  6. Toggle unique and case handling as required.
  7. Add numbering, prefixes, suffixes, and the output separator.
  8. Copy or download the output and optional stats.

Pro tip: keep the same locale and case policy across projects to make results comparable.

FAQ

Is my data stored?

No. Text and files are handled within the browser for processing and are not sent to a server.

Files are read locally and newlines are normalized during read.
How accurate is natural order?

It compares digit runs by numeric value, so 2 precedes 10. Ties fall back to standard string comparison influenced by locale.

Which separators are supported?

Newline, comma, semicolon, space, and tab are available for both splitting and joining.

Can I remove duplicates?

Yes. Enable the unique option to drop repeats after preprocessing and filtering.

Does shuffle repeat items?

No. Shuffle permutes the list without repeats. Provide a seed to recreate the same order later.

Can I use it offline?

Once the page is loaded, processing does not require network access. Availability depends on the host page and your cache.

What does “Average words per item” mean?

It is the mean count of whitespace‑separated tokens per line after all processing and sorting have been applied.

Is there a cost or license?

Refer to the site’s terms for licensing and any usage conditions.

Troubleshooting

  • No change after sorting — pick a mode other than reverse when the list is short.
  • Unexpected order — set the locale explicitly and review case sensitivity.
  • Regex not working — check the pattern and allowed flags.
  • Duplicate items remain — enable unique after preprocessing.
  • Numbers look wrong — verify natural vs alphabetical selection.
  • Line numbers misaligned — they pad to the digits in the final count.
  • Strange blanks — enable trim and ignore blank lines.

Advanced Tips

  • Use a shared seed to reproduce shuffle results across teammates.
  • Ignore articles when sorting titles so key words surface first.
  • Collapse internal spaces to align names copied from spreadsheets.
  • Strip leading numbers to clean up pasted ordered lists.
  • Set the output newline style to match your target platform.
  • Preview counts to catch outliers before sharing the list.

Glossary

Alphabetical order
Character by character comparison using the selected locale.
Natural order
Comparison that treats digit runs as numbers inside strings.
Locale
Language and region rules that affect string comparison.
Regex
A pattern used to include only matching items.
Joiner
The separator used when assembling the final output text.
Seeded shuffle
A permutation driven by a seed so results can repeat on demand.