Line Sorter
Sort lines alphabetically, numerically, or by length.
📘 How It Works
Line Splitting
Text is split on newline characters (\n) to create an array of lines. Each line becomes an element to be sorted independently.
Alphabetical Sort
Uses JavaScript's localeCompare() for proper alphabetical ordering that respects language rules. Ignoring case converts both strings to lowercase before comparison.
Numeric Sort
Extracts numbers from each line using regex /[\d.]+/. Lines are sorted by these numeric values, handling decimals correctly (1, 2, 10 not 1, 10, 2).
Length & Reverse Sort
Length sorting compares string.length values. Reverse simply reverses the current array order without considering content.
Fisher-Yates Shuffle
Random ordering uses the Fisher-Yates algorithm for true randomization. Each element has equal probability of landing in any position.
💡 Common Use Cases
Alphabetizing Lists
Sort names, terms, or items alphabetically for directories, glossaries, or organized documentation.
Data Cleaning
Sort CSV or data files by line to identify duplicates, find patterns, or prepare for processing.
Code Organization
Sort import statements, constant definitions, or configuration entries alphabetically for cleaner code.
Randomizing Contestants
Shuffle lists for random selection, prize drawings, or assigning random order for presentations.
Priority Sorting
Sort numbered items (1. Task, 2. Task) to reorder by priority or sequence numbers.
Bibliography Formatting
Alphabetize references and citations for academic papers and research documents.