Reverse a Numbered List

Learn how to reverse the order of items in a numbered list while optionally renumbering them. Useful for reordering priorities, to-do lists, and ranked items.

Practical Use Cases

Detailed Explanation

Reversing Numbered Lists

Reversing a numbered list involves flipping the order of items and optionally updating the numbers to reflect the new order.

Simple Line Reversal

The most basic approach is to reverse the lines:

Input:
1. First item
2. Second item
3. Third item
4. Fourth item

Output (line reversal):
4. Fourth item
3. Third item
2. Second item
1. First item

With Renumbering

Often you want the numbers to restart from 1 in the new order:

Output (renumbered):
1. Fourth item
2. Third item
3. Second item
4. First item

Implementation

function reverseNumberedList(text) {
  const lines = text.split("\n").filter(l => l.trim());
  // Strip existing numbers
  const items = lines.map(l => l.replace(/^\d+\.\s*/, ""));
  // Reverse and renumber
  return items.reverse()
    .map((item, i) => `${i + 1}. ${item}`)
    .join("\n");
}

Types of Lists

Ordered (numbered):

1. Buy groceries
2. Cook dinner
3. Do dishes

Bulleted (no numbers):

- Buy groceries
- Cook dinner
- Do dishes

For bulleted lists, simple line reversal works perfectly since there are no numbers to update.

Practical Applications

  • Priority reversal: Turning a "most important first" list into "least important first"
  • Bottom-up planning: Reversing a top-down task breakdown
  • Countdown creation: Converting a sequential list into a countdown
  • Schedule reversal: Flipping the order of agenda items
  • Ranking inversion: Seeing the lowest-ranked items at the top

Use Case

Project managers, content writers, and students use list reversal when reprioritizing task lists, creating countdowns, reorganizing outlines, and reformatting ranked content. It is also useful in data processing when order of records needs to be inverted.

Try It — Reverse Text

Open full tool