How to Sort Text Lines by Alphabetical, Numeric, or Length Order
Paste one item per line, choose alphabetical, numeric, length, or random sorting, and optionally reverse the result, compare case, or remove duplicates. The tool returns the lines in the selected order.
Choose a sorting method for your list
Sort Lines organizes newline-separated text when you need a cleaner list, a predictable alphabetical order, numeric ordering, or a quick length-based arrangement. Paste one item per line, then choose the comparison method that matches the data. The default is alphabetical sorting, while additional options let you reverse the final order, compare letter case, remove duplicates, or shuffle the lines.
How to sort the lines
-
Prepare the text with one item on each line. Newline characters separate the input into individual lines, so do not place several independent items on one line if they need to be sorted separately.
-
Paste or type the lines into the tool.
-
Select a sorting mode. Use alphabetical sorting for words or labels, numeric sorting for numbers, length sorting to arrange lines by character count, or random sorting to shuffle them. If you do not select another mode, alphabetical sorting is used.
-
For alphabetical sorting, decide whether letter case should affect comparisons. The default comparison is case-insensitive. Enable case-sensitive processing when the original uppercase and lowercase values need to influence the order.
-
Turn on duplicate removal if repeated entries should be omitted. The tool keeps the first occurrence of each line. Without case-sensitive processing, duplicate comparison is case-insensitive.
-
Enable reverse order when you want the final order reversed. This applies after the selected sorting operation, including numeric, length, or alphabetical sorting.
-
Review the output and copy the reordered lines for the next step in your workflow. If you use random sorting, treat the arrangement as changeable rather than as a stable sequence.
Understand the result
The output keeps the data as separate lines and changes their order according to the selected mode. Alphabetical sorting compares lines without regard to case unless case-sensitive processing is enabled. Numeric sorting trims surrounding whitespace before converting each line to a floating-point number, so it is intended for number-like input rather than strict validation. A line that cannot be converted is assigned a numeric sorting value of zero instead of producing a reported conversion failure.
Length sorting uses each line's character count. Duplicate removal keeps the first occurrence and uses case-insensitive comparison unless case-sensitive processing is enabled. Random sorting is different from the other modes: its order can vary between executions, so do not use it when you need a reproducible sequence.
An empty input is handled successfully and produces zero input lines and zero output lines. For a list that needs both cleanup and ordering, you can remove duplicates and apply the chosen sort in the same operation, then inspect the resulting line order before using it elsewhere.
Worked example
You have three newline-separated numbers and want the smallest value first.
Enter the three lines “12”, “3”, and “2”, select numeric sorting, and review the output.
The output contains three separate lines in numeric order: 2, 3, then 12.
Limitations
- Random order is not stable between executions, and numeric mode does not validate that every line is numeric because non-convertible lines are assigned a sorting value of zero.
Common errors
- A list containing labels or other non-numeric lines is sent through numeric sorting. Check the input before choosing this mode, because a line that cannot be converted is assigned a numeric sorting value of zero rather than triggering a conversion error.
FAQ
Can I sort text with case sensitivity?
Yes. The default alphabetical comparison is case-insensitive. Enable case-sensitive processing when uppercase and lowercase values should affect the comparison.
What happens if a line is not a number?
Yes, but numeric sorting is not strict validation. Surrounding whitespace is trimmed before conversion, and a line that cannot be converted is assigned a numeric sorting value of zero.
Will random sorting return the same order every time?
Random sorting shuffles the lines, so the order can vary between executions. Use alphabetical, numeric, or length sorting when you need an order based on the content.