ETEvoraTools
Text Formatting

Sort Lines Alphabetically

Sort Lines Alphabetically normalizes CRLF, then sorts every line with localeCompare under the browser's default locale. It includes blank lines and leading/trailing spaces, performs no case folding, numeric option, natural-file-name policy, stable-key selection, or locale selector. Results can vary across locale/runtime settings and are not a bytewise deterministic order.

Runs locally — files stay on your device
Quick answer

Is sorting bytewise and locale-independent?

No.

Alphabetical order depends on collation

Locale collation defines how case, accents, punctuation, and scripts compare; different consumers can choose different rules.

How it works

JavaScript Array.sort invokes a.localeCompare(b) and joins with LF.

Key concepts

Default locale

No explicit language is passed.

Whole-line key

The complete string, including spaces, is compared.

When to use it

  • Alphabetize a small human-language list.
  • Inspect entries in local browser collation.
  • Prepare a casual sorted copy.

When not to use it

  • Do not use for cryptographic canonicalization.
  • Do not assume numeric natural ordering.
  • Do not expect spaces/case ignored.

Worked examples

Simple

Input
banana\napple
Expected output
apple\nbanana

Ascending local collation.

Numbers

Input
10\n2
Expected output
May place 10 before 2

numeric option is absent.

Leading space

Input
a\n b
Expected output
Collation-dependent

Space participates.

Common mistakes

Assuming reproducibility

Locale can differ. Correction: Specify a collation externally.

Expecting natural numbers

No numeric option. Correction: Parse and sort numbers.

Ignoring blank lines

They are sorted too. Correction: Remove them first if intended.

Best practices

  • Normalize text intentionally.
  • Specify locale and numeric policy for production.
  • Verify accented and case variants.

Related operations and differences

Add Prefix to Every Line

Choose Add Prefix to Every Line when you need to add the same prefix before every line.; use Sort Lines Alphabetically specifically for sort lines.

Add Suffix to Every Line

Choose Add Suffix to Every Line when you need to add the same suffix after every line.; use Sort Lines Alphabetically specifically for sort lines.

Capitalize Every Word

Choose Capitalize Every Word when you need to capitalize the first character of every word.; use Sort Lines Alphabetically specifically for sort lines.

Character Counter

Choose Character Counter when you need to count Unicode characters in text.; use Sort Lines Alphabetically specifically for sort lines.

Extract Email Addresses

Choose Extract Email Addresses when you need to find unique email addresses in text.; use Sort Lines Alphabetically specifically for sort lines.

Extract URLs

Choose Extract URLs when you need to find unique HTTP and HTTPS links in text.; use Sort Lines Alphabetically specifically for sort lines.

Limitations and privacy

  • Ascending default-locale whole-line sort only; no locale selector, case/diacritic options, numeric/natural mode, key extraction, blank policy, or canonical guarantee.

Text is transformed locally in this browser and is not uploaded by the tool.

Frequently asked questions

Are blank lines included?

Yes.

Is sorting case-insensitive?

No explicit case folding occurs.

Are numbers sorted numerically?

No.

Can results vary by locale?

Yes.

References