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.
short_names = ["Jan", "Sam", "Ann", "Joe", "Tod"]
short_names.sort(reverse=True)
print(short_names)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:
list.sort(*, key=None, reverse=False)For reverse alphabetical order, set reverse=True. Default sorting is A–Z; reverse=True flips each comparison so strings sort Z–A.
names = ["Jan", "Sam", "Ann", "Joe", "Tod"]
print("Before:", names)
names.sort(reverse=True)
print("After:", names)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:
names = ["Jan", "Sam", "Ann", "Joe", "Tod"]
result = names.sort(reverse=True)
print(result)
print(names)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:
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:
sorted(iterable, *, key=None, reverse=False)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)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():
display_order = ["Jan", "Sam", "Ann", "Joe", "Tod"]
print_order = sorted(display_order, reverse=True)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:
words = sorted("python", reverse=True)
print(words)
pairs = ("Ann", "Joe", "Sam")
print(sorted(pairs, reverse=True))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):
names = ["Jan", "Sam", "Ann", "Joe", "Tod"]
names.sort(reverse=True)
print(names)reverse() — flip whatever order the list already has, without sorting:
names = ["Joe", "Tod", "Ann"]
names.reverse()
print(names)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:
names = ["jan", "Sam", "ann"]
print(sorted(names, key=str.lower, reverse=True))You should see ['Sam', 'jan', 'ann']. Apply the same key with sort() when sorting in place.
Mistakes to avoid
- Calling
short_names.sort()withoutreverse=Truewhen the task asks for reverse alphabetical order. - Assigning
x = mylist.sort(reverse=True)—xbecomesNone. - Using
reverse()when you need reverse alphabetical sorting. - Sorting mixed-case names without
key=str.lowerwhen 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.

