text tool

Sort lines alphabetically

Paste a list with one item per line and choose an order: A to Z, Z to A, smallest or largest number first, shortest or longest first, or a random shuffle. Alphabetical sorting follows your browser's language, so accented letters and numbers inside text land where a reader expects.

Loading the tool…

How it works

  1. 1

    Paste the list

    One item per line. The sorted list appears beside it as you type.

  2. 2

    Pick an order

    A to Z, Z to A, Smallest number first, Largest number first, Shortest first, Longest first, or Shuffle. The arrow keys move between them.

  3. 3

    Set the details

    Numbers inside text in number order puts Item 2 before Item 10. Capitals before lower case sorts like a computer. Ignore a leading The, A or An files The Lantern under L.

  4. 4

    Copy the result

    Copy it, download it as a .txt file, or use it as the input for another pass. Nothing is uploaded and nothing is stored, ever.

Why language aware sorting matters

A plain computer sort compares character codes, which puts every capital letter before every lower case one and sends accented letters after z, so Zebra lands before apple and éclair after zoo. This tool sorts with the browser's built in collator, which follows the Unicode Collation Algorithm and the rules for your language: capitals and lower case sit together, and é sorts with e. Tick Capitals before lower case if you need the plain code order, for example to match a program's output.

Numbers inside text

Sorted character by character, Item 10 comes before Item 2, because the character 1 is lower than 2. Natural number order compares runs of digits as whole numbers instead, so Item 1, Item 2 and Item 10 come out in that order. For lines that are mostly numbers, such as prices, postcodes or scores, choose Smallest number first: the first number in each line is read, 1,250 is read as one thousand two hundred and fifty, and lines with no number go to the end.

Ordering options for a form

A long dropdown is easier to use when its options are alphabetical, such as countries, suburbs or departments. A short list with a natural order, such as sizes from small to extra large or a rating from poor to excellent, should keep that order, because sorting it would scramble the scale. Sort the list here, check that no option needs to stay first or last, such as Other, and then use it. The form generator takes a prompt of up to 10,000 characters, room for a long sorted list.

Shuffling fairly

Shuffle uses the Fisher Yates method with numbers from the browser's cryptographic random generator, redrawing any number that would favour some positions, so every order of the list is equally likely. That makes it fit for a random order of speakers, a running order for a quiz or a draw from a list of entries. Press Shuffle again for a new order. The shuffle ignores the other settings, apart from Remove empty lines, so blank lines do not end up scattered through the result.

Limits worth knowing

Alphabetical order depends on language. Your browser's language is used and shown under the result, and a machine set to Swedish puts Å after Z where an English one files it with A, so the same list can sort differently on two computers. Numeric sorting reads only the first number in each line, so Room 3, 12 guests sorts by 3. A decimal comma, as in 3,5, is read as 3. And every line is one item, so an entry that runs over two lines needs joining first.

Limits

  • Language aware sorting follows the browser's language, so accented letters order differently across machines. The language in use is shown under the result.
  • Numeric sorting reads the first number in each line; lines with no number go to the end in their original order.
  • A shuffle cannot be repeated: every press gives a new order and the last one is not kept.

What it does not do

  • It does not remove duplicates; the remove duplicate lines tool does.
  • It does not sort by a column inside each line, such as the second field of a CSV row.
  • It does not keep an entry that runs over two lines together as one item.

Questions people ask

How do I sort lines in Word or Google Docs?

In Word, select the lines and use Sort in the Paragraph group on the Home tab. Google Docs has no built in sort for lines, so most people paste into a spreadsheet or install an add on. Pasting here works from any source and adds orders a word processor lacks, such as by length, by number and shuffle.

Can I sort a list of names by surname?

Not directly, because each line is sorted from its first character. Rewrite the names as surname, then first name, which a spreadsheet can do with a formula, and sort them here. For a short list it is often quicker to retype them. Ignore a leading The, A or An helps with titles, not names, so leave it off for people.

What happens to empty lines?

With Remove empty lines ticked, they are dropped and the summary says how many. Untick it to keep them: they then sort to the top in A to Z order, because an empty line comes before any letter, and to the bottom in Z to A. A line holding only spaces counts as empty either way.

Is the shuffle random enough for a prize draw?

It uses the browser's cryptographic random generator and the Fisher Yates method, so no entry is favoured by its place in the list. For a public draw, record your screen as you paste and shuffle, since the result is not saved and cannot be reproduced later. Check your local rules too, as some promotions need an independent scrutineer.

Does it sort decimals and negative numbers?

Yes, in the numeric orders. The first number in each line is read with its minus sign and decimal point, so -2.5 comes before 0 and 0.75 before 1. Thousands written with commas, as in 12,500, are understood. A decimal comma, used in much of Europe, is not: 3,5 is read as 3, so change those to points first.

Is my list uploaded?

No. Sorting happens in this page on your device, and no network request carries the text, which you can check in the network tab of your browser. Nothing is stored, so a customer list, a class roll or a set of internal codes leaves no copy behind once you close or refresh the tab.

Use the sorted list in a form

Take what you made here into forms.

Create a form with OneCraft

More tools like this

Background reading: the question page on this.

Sources

Written and checked by the OneCraft team. Last checked .