Home / Text tools / Sort lines in reverse

Sort Lines in Reverse Order

Sort your lines from Z to A, or simply flip them so the last line comes first.

Two kinds of reverse

People mean two different things by reverse order, so this page offers both.

  • Sort Z to A: orders lines in reverse alphabetical order. Banana, Apple, Cherry becomes Cherry, Banana, Apple.
  • Reverse current order: flips the lines exactly as they are, without sorting. The last line becomes the first.

When to flip

Flipping is the right choice for logs and histories that are written oldest first when you want the newest at the top, for numbered steps you want to count down, and for any list where the existing order matters but you need it backwards.

When to sort Z to A

Use Z to A when you want a reverse alphabetical list, such as names from the end of the alphabet first. Case is ignored by default, and you can tick options to remove duplicates or empty lines.

Example

The lines first entry, second entry, third entry and fourth entry flipped become fourth entry, third entry, second entry, first entry.

For A to Z use sort lines alphabetically. For numbers or lengths, use the main sort lines tool. The guide shows the same on the command line.

Frequently asked questions

What is the difference between sorting Z to A and reversing?

Z to A sorts by letters in reverse. Reversing flips the existing order and does not look at the letters.

How do I put the last line first?

Choose Reverse current order.

Does reversing keep my lines unchanged?

Yes, unless you tick cleanup options such as Trim lines or Remove duplicates.