How to Sort Lines: Browser, GNU sort, VS Code or Excel?

Use a browser tool for a quick pasted list, GNU sort for repeatable file workflows, VS Code for text already in your editor, and Excel for rows that belong together.

Choose by the data you have

MethodBest fitWatch for
SortLinesPaste, configure, review and copyBrowser memory and device limits
GNU sortFiles and repeatable scriptsLocale and option differences across systems
VS CodeA selection already in a text fileSort Lines Ascending is alphabetical
ExcelTables with linked columnsSort the entire table so rows stay aligned

Sort a pasted list online

Open Sort Lines, paste one item per line, choose a mode and review cleanup changes. Use Natural sort for file2/file10 or Numeric sort for complete numeric values. Then copy or download the output.

Sort files with GNU sort

sort input.txt > sorted.txt
sort -g numbers.txt > numbers-sorted.txt
sort -r input.txt > descending.txt
sort -u input.txt > unique-sorted.txt
sort -V filenames.txt > filenames-sorted.txt

These examples target GNU Coreutils. -g compares general numeric values, -r reverses the ordering, -u emits unique comparisons and -V uses version sorting. Version sorting and this site's locale-aware natural sorting need not produce the same result. Use a different output filename: redirecting into the input file can truncate it before sorting.

Sort selected lines in VS Code

Select the complete lines, open the Command Palette and run Sort Lines Ascending or Sort Lines Descending. These commands do not provide the same numeric or cleanup controls as this tool.

Keep spreadsheet rows together

In Excel, select the full table and use Data → Sort on the intended column. Sorting only one column can disconnect a name from its associated email or ID. For a standalone pasted column, a line sorter is sufficient.

Sources and further reading

GNU Coreutils: sort invocation · VS Code: built-in line operations · Microsoft: sort data in a range or table