Skip to content
100% local

Sort lines by word position

Sort lines by a specific word within each line, not the whole line.

Input
Output

Sort lines by word position

Sort lines by word position reorders your text using one specific word from each line as the sort key, instead of comparing entire lines from the start. It's built for lists where the field you actually want to sort by isn't the first thing on the line — a roster written "Last First", a log line where the timestamp sits after a tag, or a dump of space-separated columns pasted straight from a spreadsheet.

Paste your lines and set the word position: 1 sorts by the first word, 2 by the second, and so on up to 20. Each line is split on whitespace, so runs of spaces or tabs between words count as a single separator and don't throw off the count. If a line has fewer words than the position you chose, the tool falls back to that line's last word as the key, so short or ragged lines still land somewhere sensible instead of breaking the sort. A completely empty line sorts as an empty key.

Two options refine the comparison. Descending order reverses the result — useful for "newest first" or "highest first" lists once you've picked the right word. Case-sensitive comparison switches from the default locale-aware, case-insensitive comparison to one that distinguishes uppercase from lowercase, which matters for tags, codes, or identifiers. The sort is stable, so lines sharing the same key keep their original relative order.

Typical uses include alphabetizing a name list by surname when it's formatted "Given Family", or straightening out any space-delimited list by the column that actually matters. Everything runs locally in your browser — your text is never uploaded, so pasting sensitive lists like contact rosters stays private.

FAQ

What happens if a line has fewer words than the position I chose?
The tool uses that line's last word as the sort key instead, so short lines are still placed in a sensible order rather than being pushed to one end.
How are words separated?
Any run of whitespace — spaces or tabs — counts as one separator, so extra spacing between words does not change which word ends up at a given position.
Does the sort respect accented letters correctly?
Yes. Comparison uses your browser's locale-aware collation, so accented letters like á, č, or ž sort in their natural alphabetical place rather than after plain letters.
What if two lines have the same word at that position?
The sort is stable, so lines with identical keys keep their original order relative to each other — they are not reshuffled.
Is my text uploaded anywhere?
No — it never leaves your browser; everything runs locally on your device.