AiLounge Tools

Text Cleanup & List Tools

Deduplicate lines, trim whitespace, sort, change case and count Unicode — all locally in your browser, never uploaded.Processed locally · no backend

Sort lines (lex / numeric / length)

Three modes: lexicographic (declared locale — en Intl.Collator by default, or deterministic codepoint order), numeric (full-line numbers, 2/10/1 → 1/2/10) and grapheme-length; ascending/descending. Result metadata names the mode and locale.

Run in browser

Inputs and parameters

Real example

2
10
1   →   numeric mode
→ 1
2
10   (lexicographic mode is separately labelled 1
10
2: locale=en uses Intl.Collator string compare; locale=codepoint is deterministic code-point order)

Limits and failure handling

Lexicographic order depends on the runtime Intl.Collator / ICU version (hence the deterministic codepoint option and the declared locale in metadata). Numeric mode only recognises whole-line numbers — no natural sort of embedded numbers like "Chapter 10". Length mode counts Intl.Segmenter graphemes (combining marks / ZWJ emoji = 1), not UTF-16 units. Limits 2 MiB / 100 000 lines; cancellable.

FAQ

Why does lexicographic sort put 10 before 2?

Lexicographic sorting compares strings character by character: "10" < "2" because "0" < "2", giving 1 / 10 / 2. Use numeric mode for numeric magnitude. Both are explicitly labelled in result metadata, never conflated.

Does the locale change results?

Yes. Lexicographic mode uses Intl.Collator(locale, {sensitivity:"variant", numeric:false}); accents, case and language collation can differ. Choosing codepoint uses deterministic Unicode code-point order independent of the runtime.

How are mixed numeric and non-numeric lines sorted?

In numeric mode only whole-line numbers are ordered numerically; non-numeric lines are always listed afterwards in lexicographic order. That partition does not flip with direction.