Sort Lines

Sort the lines of a text block using JavaScript's locale-aware string comparison. The operation changes order but does not trim or otherwise normalize the lines.

What this tool actually changes

The implementation splits on CRLF or LF and calls Array.sort() with localeCompare(). Because comparison is locale-aware, ordering can differ from a byte-wise ASCII sort and may vary with locale behavior.

Edge cases to know

Whitespace remains part of each line. Blank lines remain in the input and participate in sorting. If you need Unix-style byte or ASCII ordering, use an appropriate command-line or custom workflow instead.

Example

Input:
delta
alpha
charlie
beta

Output:
alpha
beta
charlie
delta

Good use cases

Alphabetizing lists, preparing deterministic review material, organizing identifiers, and getting pasted data into a consistent order.

Choose the right comparison for the job

Use the tool for a quick human-readable ordering of short lists. The implementation calls JavaScript localeCompare(); it is not a bytewise, ASCII, numeric, or guaranteed cross-locale canonical sort. If a generated file must have reproducible ordering, select explicit comparison rules in the local script or build step that owns that format.

Sorting changes meaning when order is data

Do not sort event logs, ranked results, migration steps, or other sequences where position carries chronology or priority. Blank lines remain and participate in ordering, and leading whitespace stays attached to its line.

Complexity and practical limit

Sorting requires the browser to hold all lines in memory; comparison work grows faster than the number of lines because lines must be ordered. For large files or repeatable pipelines, prefer a local command with explicitly chosen locale and options.

Frequently asked questions

Does sorting trim whitespace?

No. Lines are sorted as they are; whitespace remains part of each string.

Is this the same as Unix sort?

Not exactly. This browser tool uses JavaScript localeCompare(), while Unix sort has its own locale and option semantics.

Does it remove duplicates?

No. Sorting changes order only.

Will it produce the same order on every computer?

Do not rely on that for canonical output. Locale-aware comparisons can differ from byte-oriented sorting and may vary with runtime locale behavior.

Advertisements