Skip to content

Sort Lines

Sort a list alphabetically or by length, reverse it, or shuffle it at random. Pick the language whose rules set the order and compare numbers by value.

0 characters · 0 lines

0 characters · 0 lines

What you enter is processed only in this browser and is never sent to a server. How it works

Three lines sorted from Cherry, Apple, Banana to Apple, Banana, Cherry

How to use

Paste one value per line into “Input” and pick a mode under “Sort by”. Which options you can use depends on the mode.

  • “Direction” is available only for “Alphabetical” and “Length”. In the other two modes it is locked, with the note “This mode has no direction.”
  • “Sort language”, “Compare numbers by value (2 < 10)” and “Case sensitive” apply only to “Alphabetical”.
  • “Exclude empty lines” works in all four modes.

Sort modes

  • Alphabetical: sorts in character order. “Direction” is either “A to Z” or “Z to A”.
  • Length: sorts by the number of characters in each line. “Direction” is “Shortest first” or “Longest first”. Characters are counted as you see them on screen, so one accented letter is 1 character and so is an emoji built from several code points. Sorting été, ab, 👨‍👩‍👧 and abcd with “Shortest first” gives 👨‍👩‍👧 (1 character), ab (2), été (3), abcd (4). Lines of equal length keep the order you entered them in.
  • Reverse order: doesn’t sort. It simply reverses the current order, which is handy for flipping a newest-first log to oldest-first.
  • Shuffle: puts the lines in random order. It uses the browser’s cryptographic random numbers, and every possible order is equally likely. Press “Shuffle again” next to the result to draw a new order.

How the sort language changes the order

“Alphabetical” follows the dictionary order of the language chosen under “Sort language”. There are five to choose from: 한국어, English, 日本語, Deutsch and Español. The language of the page you are reading is selected to begin with. These are the cases where the same list comes out differently depending on that choice.

Lines entered Sort language Result
banana, 사과, Apple, 가지 한국어 가지, 사과, Apple, banana
banana, 사과, Apple, 가지 Any of the other four Apple, banana, 가지, 사과
oso, ñandú, nube, nido Español nido, nube, ñandú, oso
oso, ñandú, nube, nido Any of the other four ñandú, nido, nube, oso
Zebra, Ärger, Apfel, Azur All five Apfel, Ärger, Azur, Zebra

Under Korean rules, Korean script (here 사과, “apple”, and 가지, “eggplant”) comes before Latin letters. Under the other languages, Latin letters come first. Only Spanish rules treat ñ as a separate letter that follows n. German umlauts (ä, ö, ü) sit right beside a, o and u whichever language you pick.

In every language, lines that begin with a symbol come first, then digits, then letters. A line that begins with a space goes to the top as well, just like a symbol.

Options for numbers, case and empty lines

  • Compare numbers by value (2 < 10): when off, digits are compared one position at a time like letters, giving item1, item10, item2. When on, the numbers inside a line are read by size, giving item1, item2, item10. Use it for file names and numbered items.
  • Case sensitive: when off, apple and Apple count as equal and stay in the order you entered them. When on, lowercase comes first within the same word: apple, Apple, APPLE. Accents are told apart regardless of this option, so résumé comes after resume.
  • Exclude empty lines: drops empty lines before sorting. Only lines with no characters at all are dropped. A line holding just spaces or tabs stays and rises to the top of the result.

Frequently asked questions

After sorting, there's an empty line at the top of the result. Why?

When the input ends with a line break, whatever follows it counts as one empty line, and an empty line sorts ahead of every character. The two lines b, a with one more line break after them come out as an empty line, a, b. "Reverse order" puts an empty line on top for the same reason. Turn on "Exclude empty lines" and it goes away.

Will decimals, negative numbers and numbers with commas sort by size?

No. "Compare numbers by value (2 < 10)" reads each unbroken run of digits as a whole number and nothing more. It doesn't understand decimal points, minus signs or thousands separators. So 1.5 comes before 1.25 (it compares the 5 and the 25 after the point), -3 comes before -10 (the sign is ignored), and 1,200 comes before 30 and 950 (only the 1 before the comma is compared). For values like these, sorting them as numbers in a spreadsheet is the safer route.

Can I sort Japanese place names written in kanji by how they're pronounced?

Kanji don't sort by pronunciation. Set "Sort language" to 日本語 and sort 大阪 (おおさか), 京都 (きょうと) and 東京 (とうきょう), where the kana in parentheses spell out how each name is read, and you get 京都, 大阪, 東京. Values written in kana do sort in kana order, the order of the Japanese syllabary. If you need pronunciation order, put the kana reading at the start of each line and then sort.

Can I reproduce a "Shuffle" result later?

No. Every shuffle draws fresh random numbers from the browser, and there is no value you can set to pin the order down. Once shuffled, the order stays the same while you edit the text inside a line, but the list is reshuffled when you press "Shuffle again", when the number of lines changes or when you open the page again. If the order has to be kept, as with the result of a draw, copy it the moment it appears.

Can I sort by a particular table column or keep the header fixed?

The tool treats each line as a single value. That means some lists need tidying before you paste them in. • If the first line is a header such as "Name" or "No.", it is sorted along with the other lines and ends up somewhere in the middle. Leave the header out. • A table with columns separated by commas or tabs is compared from the first column onward. You can't sort by the second column. • Identical lines are not removed. They simply end up next to each other.

Last updated: