Text

Sort Lines of Text

Sorts lines alphabetically or in natural numeric order, so item2 comes before item10.

Loading the tool…

Processing happens locally in your browser. What you paste or load is processed by this page and is not uploaded to a server. Nothing is stored unless you use a control that says it stores something, and you can clear anything this site has kept from the privacy page.

How to use this tool

  1. Paste the lines you want sorted.
  2. Choose the direction, and leave natural ordering on if the lines contain numbers.
  3. Select Sort, then copy or download the result.

What line sorter does

Plain alphabetical sorting puts item10 before item2, because it compares character by character and 1 comes before 2. Natural sorting compares runs of digits by their value instead, which is what anybody looking at a list of versions, hostnames or numbered files actually wants. It is on by default here and can be turned off.

Sorting also uses your browser’s locale rules rather than raw code points, so an accented letter sorts next to its base letter instead of after the entire alphabet. That matters the moment a list contains a name. Case sensitivity is a separate switch, because "apple" and "Apple" being adjacent is usually what you want and occasionally is not.

Frequently asked questions

Because natural ordering is on by default, and it compares runs of digits by their value rather than character by character. Plain alphabetical ordering puts item10 first, since 1 sorts before 2. Turn natural ordering off if you specifically want the character-by-character result.

Next to their base letter, because sorting uses your browser’s locale rules rather than raw code points. A code point sort would put every accented letter after the whole of the plain alphabet, which is never what a reader expects from a list of names.

Only what your browser will comfortably hold in a text box. Sorting itself is fast; pasting several megabytes into a page is what gets slow. For files that big, sort them where they live rather than in a browser.