9.04
Completed
Sorting and Reversing Lists Sorting and Reversing Lists

Sort and reverse Python lists while staying in control of whether the original list changes.

Sorting and Reversing Lists

Sounds useful?

Jump into the interactive version.

No setup. No account. Just Python.

Interactive Python lesson

Sorting and Reversing Python Lists

A list can contain all the right values and still be in the wrong order. This Block shows you how to arrange numbers and strings with sorted() and list.sort(), switch to descending order with reverse=True, and flip the current positions with list.reverse() or a [::-1] slice.

What you will learn:

  • Create a new sorted list while keeping the original order untouched
  • Sort an existing list in place and avoid accidentally assigning its None result
  • Switch between ascending and descending sorting with reverse=True
  • Understand the difference between sorting values and reversing positions
  • Create a reversed copy with a [::-1] slice
  • Handle duplicates, negative numbers, and values that cannot be sorted together

By the end, you will know which ordering tool fits the job and whether it creates a new list or changes the one you already have.

> Start now 100 cards · about 10 min

Ready to practice this in the browser?

> Play now