How to Reverse the Order of Lines in a List
Quick ways to flip a list so the last line comes first, with uses for logs, rankings and chronological data, plus spreadsheet methods.
Sometimes a list is the right content in the wrong order: a chat export with the oldest message first, a log file you want newest-first, or a countdown you wrote from one to ten instead of ten to one.
The quick way
- Paste your list into the reverse text generator, one item per line.
- Copy the Reverse line order result.
Each line stays exactly as it was; only the order changes.
Common uses
- Chronological data: show the newest entries first.
- Rankings and countdowns: turn a "1 to 10" list into "10 to 1" for a big reveal.
- Log files: read the most recent events at the top.
- Undo steps: reverse a list of changes to plan a rollback.
- Playlists and agendas: reorder quickly for a different flow.
In a spreadsheet
- Add a helper column with numbers 1, 2, 3 and so on.
- Sort the sheet by the helper column in descending order.
- Delete the helper column.
In code and the command line
- Linux/macOS:
tac file.txtprints lines in reverse order (on macOS,tail -r file.txtworks without extra tools). - Python:
lines[::-1]on a list of lines. - JavaScript:
text.split('\n').reverse().join('\n').
Reverse vs sort
Reversing keeps your existing order and flips it. Sorting reorders items by value, such as alphabetically or by date. If your list is not already in a meaningful order, sorting is probably what you need instead.
Frequently asked questions
How to reverse a list in Python or an array in JavaScript?
To reverse a list in Python, use my_list.reverse() or reversed(my_list). To reverse an array in JavaScript, use arr.reverse() (changes the original) or arr.toReversed() (returns a copy). To flip a list of text lines without code, use the reverse line order option.
Sort vs reverse: what is the difference?
In sort vs reverse, reverse flips the current order, while sort reorders by value. On Linux, the tac command prints a file's lines in reverse order.
Try the free Reverse Text Generator
Reverse letters or words, flip text upside down and create mirror text with one click.
Open Reverse Text Generator