Sort List in Reverse Alphabetical Order in Python

Learn how to sort a Python list in reverse alphabetical order using sort(reverse=True) and sorted(reverse=True). Also see how to solve the short_names exercise and choose between in-place sorting and creating a new list.

Published

Updated

Read time 5 min read

Reviewed byDeepak Prasad

Sort List in Reverse Alphabetical Order in Python

Reverse alphabetical order means sorting strings from Z to A. In Python, pass reverse=True to list.sort() or sorted(). For the full sorted() / key= reference, see Python sort; for reverse iteration without sorting, see print a list in reverse order with range.

For the common exercise: if short_names is ['Jan', 'Sam', 'Ann', 'Joe', 'Tod'], then short_names.sort(reverse=True) gives ['Tod', 'Sam', 'Joe', 'Jan', 'Ann'].

Tested on: Python 3.13.3; kernel 6.14.0-37-generic.


Quick reference

Task Use
Sort the same list in reverse alphabetical order list.sort(reverse=True)
Create a new reverse-sorted list sorted(list_name, reverse=True)
Keep the original list unchanged sorted()
Modify the original list sort()
Sort case-insensitively key=str.lower, reverse=True
Reverse current list order only reverse() or list[::-1]

Sort short_names in reverse alphabetic order

This matches the exact exercise wording: sort short_names itself in reverse alphabetical order.

python
short_names = ["Jan", "Sam", "Ann", "Joe", "Tod"]
short_names.sort(reverse=True)
print(short_names)
Output

You should see ['Tod', 'Sam', 'Joe', 'Jan', 'Ann']. reverse=True tells Python to sort with comparisons reversed—A–Z becomes Z–A for strings.

Do not replace user input with a hard-coded list in homework-style code unless the assignment allows it; the pattern is the same whether names come from a literal or from input().


Method 1: Use sort(reverse=True)

list.sort() is a list method—call it on the variable you want to reorder:

python
list.sort(*, key=None, reverse=False)
Output

For reverse alphabetical order, set reverse=True. Default sorting is A–Z; reverse=True flips each comparison so strings sort Z–A.

python
names = ["Jan", "Sam", "Ann", "Joe", "Tod"]
print("Before:", names)
names.sort(reverse=True)
print("After:", names)
Output

You should see the original order first, then ['Tod', 'Sam', 'Joe', 'Jan', 'Ann']. The same list object is updated—nothing new is allocated for the container itself.

Return value: sort() always returns None, not the sorted list:

python
names = ["Jan", "Sam", "Ann", "Joe", "Tod"]
result = names.sort(reverse=True)
print(result)
print(names)
Output

You should see None, then the sorted list in names. That is why short_names.sort(reverse=True) is the right exercise answer when the grader checks short_names afterward—not result = short_names.sort(...).

When to use: You are done with the old order and want the list itself updated—updating a roster in memory, reordering results before the next loop, or homework that says “sort short_names.”

With input: the pattern is unchanged; only the source of the list differs:

python
short_names = []
while True:
    name = input("Enter a name (blank to finish): ").strip()
    if not name:
        break
    short_names.append(name)

short_names.sort(reverse=True)
print(short_names)

See Python sort() for key, custom ordering, and more examples.


Method 2: Use sorted(reverse=True)

sorted() is a built-in function that works on any iterable and always gives you a new list:

python
sorted(iterable, *, key=None, reverse=False)
Output
python
names = ["Jan", "Sam", "Ann", "Joe", "Tod"]
original = names.copy()
reversed_alpha = sorted(names, reverse=True)

print("New list:", reversed_alpha)
print("Original unchanged:", names)
print("Same object?", names is reversed_alpha)
Output

You should see Z–A order in reversed_alpha, the starting order still in names, and False for is—two separate lists.

Correct assignment: store the return value of sorted(), not the result of sort():

python
display_order = ["Jan", "Sam", "Ann", "Joe", "Tod"]
print_order = sorted(display_order, reverse=True)
Output

Use the sorted copy for printing or passing to another function while display_order stays as entered.

Other iterables: sorted() is not limited to lists pre-built as literals:

python
words = sorted("python", reverse=True)
print(words)

pairs = ("Ann", "Joe", "Sam")
print(sorted(pairs, reverse=True))
Output

You should see ['y', 't', 'p', 'o', 'n', 'h'] and ['Sam', 'Joe', 'Ann']. Convert a string to a list of characters, or sort a tuple, without mutating the source.

When to use: You need reverse alphabetical order for output or further processing but must keep the original sequence—logging, “before and after” displays, or building a new list while leaving the input list for later steps.


sort() vs sorted()

Feature sort() sorted()
Works on Lists only Any iterable
Changes original list Yes No
Returns None New sorted list
Best for Updating the same list Keeping original data

Use sort() when you want to change the list itself. Use sorted() when you need a new list and want to keep the original unchanged.


reverse=True vs reverse()

They are not the same.

reverse=True — sort in descending alphabetical order (Z–A for names):

python
names = ["Jan", "Sam", "Ann", "Joe", "Tod"]
names.sort(reverse=True)
print(names)
Output

reverse() — flip whatever order the list already has, without sorting:

python
names = ["Joe", "Tod", "Ann"]
names.reverse()
print(names)
Output

You should see ['Ann', 'Tod', 'Joe']—not reverse alphabetical. If the list was not sorted first, reverse() is not a substitute for sort(reverse=True).


Sort names case-insensitively

Python compares strings by character code. Mixed case can sort unexpectedly ("Sam" before "ann"). For natural name order, use key=str.lower:

python
names = ["jan", "Sam", "ann"]
print(sorted(names, key=str.lower, reverse=True))
Output

You should see ['Sam', 'jan', 'ann']. Apply the same key with sort() when sorting in place.


Mistakes to avoid

  • Calling short_names.sort() without reverse=True when the task asks for reverse alphabetical order.
  • Assigning x = mylist.sort(reverse=True)x becomes None.
  • Using reverse() when you need reverse alphabetical sorting.
  • Sorting mixed-case names without key=str.lower when case should be ignored.
  • Replacing required user input with a hard-coded list in exercise submissions.

Summary

Use sort(reverse=True) to sort the same list from Z to A. Use sorted(names, reverse=True) to build a new reverse-sorted list. reverse=True is sorting in descending order; reverse() only reverses the current sequence. For names with mixed case, add key=str.lower. For the short_names exercise, short_names.sort(reverse=True) is the direct answer.


Frequently Asked Questions

1. How do you sort short_names in reverse alphabetic order?

Call short_names.sort(reverse=True) to sort the list in place from Z to A—for example Tod, Sam, Joe, Jan, Ann.

2. What is the difference between sort() and sorted() in Python?

list.sort() modifies the list in place and returns None; sorted() returns a new sorted list and leaves the original unchanged.

3. Is reverse=True the same as reverse()?

No—reverse=True sorts in descending alphabetical order; reverse() only flips the current list order without sorting.

4. How do you sort names case-insensitively in reverse order?

Use sorted(names, key=str.lower, reverse=True) or names.sort(key=str.lower, reverse=True).

5. Can you assign the result of sort() to a variable?

You should not—sort() returns None, so x = mylist.sort(reverse=True) sets x to None while mylist is sorted in place.
Azka Iftikhar

Computer Scientist

Proficient in multiple programming languages, including C++, Golang, and Java, she brings a versatile skillset to tackle a wide array of challenges. Experienced Computer Scientist and Web Developer, …