Sort Lines Alphabetically — Online Line Sorter (A-Z, Z-A, Numeric)
Paste any line-separated input — a name list, a numeric column from a spreadsheet, log timestamps, or whatever you need ordered — and pick a sort: alphabetical (A-Z), reverse alphabetical (Z-A), numeric (treats each line as a number), or random shuffle. Sorting runs reactively as you type or change options, the result appears below in real time, and a single Copy button puts the sorted output on your clipboard. Useful for ordering a CSV column before pasting it back into Excel, prioritizing tickets by ID number, randomizing a list of names for a draft order, or just turning chaos into order in 5 seconds without firing up a script.
About this tool
Alphabetical sorting uses `String.prototype.localeCompare`, which is locale-aware — accented characters sort with their base letter (`á` near `a`, `ñ` after `n` in Spanish locale rules) instead of falling to the bottom by Unicode code point. The case-sensitive toggle controls whether `Apple` and `apple` are equal (it just lowercases both sides of the comparator when off). Numeric sort uses `parseFloat` per line, which means lines that don't parse to numbers fall back to `0` and cluster at the start — useful if you want to surface non-numeric outliers from a numeric column. Random shuffle uses the same Fisher-Yates over Web Crypto entropy as the random-number tool — every permutation is equally likely, no Math.random modulo bias. The whole pipeline is reactive: changing the input, the mode, or the case toggle re-sorts instantly. Use cases: ordering a CSV column before re-pasting it, prioritizing JIRA tickets by ID, randomizing a draft pick order, sorting a wordlist for binary search, alphabetizing import statements in a code file, or shuffling a playlist of song titles.
- Alphabetical A-Z using locale-aware localeCompare (handles ñ, á, ö correctly)
- Reverse Z-A using the same locale-aware comparator
- Numeric mode via parseFloat — non-numbers cluster at start as 0
- Random shuffle via Fisher-Yates over Web Crypto entropy
- Optional case sensitivity (Apple vs apple equal when off)
- Reactive — re-sorts on any input/mode/case change
- One-click copy of the sorted result
- Handles 10,000+ lines in milliseconds
- Empty lines preserved at the position dictated by the comparator
- Useful for CSV columns, ticket prioritization, draft picks, wordlists, imports
Free. No signup. Your inputs stay in your browser. Ads via Google AdSense (consent required).
Frequently asked questions
Why does sorting accented characters work differently in different locales?
Sorting accented characters depends on the active locale's collation rules, not raw Unicode code-point order. The Unicode Collation Algorithm (UTS #10, Whistler & Scherer eds., revision 51 tied to Unicode 16.0) defines the Default Unicode Collation Element Table — base letters first, with accents and case as secondary and tertiary weights — but locale-specific tailorings from CLDR (Common Locale Data Repository) override the defaults for languages whose conventions differ. In Spanish, for example, ñ is a distinct letter sorting after n (so 'naranja' precedes 'ñame'), while default UCA places ñ together with n. Both ECMA-262 String.prototype.localeCompare and ECMA-402 Intl.Collator delegate to UCA + CLDR, so the result depends on which locale is active when the sort runs.
How does the random shuffle ensure every order is equally likely?
The shuffle implements Fisher-Yates — originally Fisher & Yates 1938 (Statistical Tables for Biological, Agricultural and Medical Research, pen-and-paper using a random-number table), then Durstenfeld 1964 (CACM 7(7):420, Algorithm 235) for the in-place computer form, popularized as Algorithm P (Shuffling) in Knuth's The Art of Computer Programming Vol 2 §3.4.2. The algorithm walks the array right-to-left, at index i picking a random index j in [0, i] and swapping. Every permutation appears with equal probability provided the random source is unbiased — this tool draws entropy from crypto.getRandomValues() (W3C Web Cryptography API, Recommendation 26 January 2017) and applies rejection sampling to map 32-bit values into [0, i+1] without the modulo bias that affects naive Math.floor(Math.random() * n) implementations.
What does parseFloat do with non-numeric lines in numeric mode?
parseFloat on a non-numeric input returns NaN. Per ECMA-262, when a comparator returns NaN the spec treats it as 0 (equal), and ES2019 made Array.prototype.sort stable — so non-parseable lines keep their original relative order rather than getting a deterministic numeric position, while the parseable lines around them are sorted numerically. In practice this means a numeric column with stray text, dates, or empty lines does not silently push non-conforming entries somewhere predictable — those entries cluster wherever they originally were among other non-numbers. Pre-filtering the input with text-replace to strip non-numeric lines first gives a clean numeric-only sort.
Why does case-insensitive mode not change the displayed lines?
The case option controls only the comparator. With case-insensitive mode on, both sides are lowercased before comparison, so 'Apple' and 'apple' are treated as equal — but the lines that appear in the output retain their original casing. This matches the convention of database COLLATE NOCASE and Excel's case-insensitive sort: capitalization, leading whitespace, and other display-only differences are preserved even though they did not influence ordering. The behaviour is deterministic across re-runs because both localeCompare and the input lines are stable.
How does this tool handle accessibility for screen readers?
The sorted result region is marked aria-live="polite", the W3C WCAG Success Criterion 4.1.3 (Status Messages, introduced in WCAG 2.1, Recommendation 5 June 2018; carried unchanged into WCAG 2.2, Recommendation 5 October 2023) pattern. Polite is appropriate because the sort isn't urgent — it queues announcements behind any speech the user is hearing rather than interrupting mid-sentence. Screen readers (NVDA, JAWS, VoiceOver) consume the live region automatically; nothing else is required from the user.
Sources (9)
- Whistler, K., & Scherer, M. (Eds.) (2024). UTS #10: Unicode Collation Algorithm. Unicode Technical Standard, revision 51 (tied to Unicode 16.0, August 2024).
- Unicode CLDR Project (2024). Common Locale Data Repository — Collation Tailorings. Unicode Consortium, cldr.unicode.org.
- ECMA International (2025). ECMAScript 2025 Language Specification — String.prototype.localeCompare. ECMA-262, 16th edition, June 2025.
- ECMA International (2025). ECMAScript 2025 Internationalization API Specification — Intl.Collator. ECMA-402, 12th edition, June 2025.
- Fisher, R. A., & Yates, F. (1938). Statistical Tables for Biological, Agricultural and Medical Research (1st ed.). Oliver and Boyd, London — original pen-and-paper shuffle algorithm.
- Durstenfeld, R. (1964). Algorithm 235: Random permutation. Communications of the ACM, 7(7), 420 (in-place computer form of Fisher-Yates).
- Knuth, D. E. (1997). The Art of Computer Programming, Vol. 2: Seminumerical Algorithms — §3.4.2 Algorithm P (Shuffling). Addison-Wesley, 3rd edition (popularized the in-place Fisher-Yates as Algorithm P).
- World Wide Web Consortium (W3C) (2017). Web Cryptography API — crypto.getRandomValues(). W3C Recommendation, 26 January 2017.
- World Wide Web Consortium (W3C) (2018). Web Content Accessibility Guidelines (WCAG) 2.1 — Success Criterion 4.1.3 Status Messages. W3C Recommendation 5 June 2018; carried unchanged into WCAG 2.2 (Recommendation 5 October 2023).
These are the original publications the formulas in this tool are based on. Locate them by journal name and year on Google Scholar or PubMed.