Skip to content
masterclass Buddy

Python · Function

range

sorted() returns a new list with the items from an iterable in sorted order. Use key to control comparisons and reverse=True for descending order.

Last updated

Syntax

sorted(iterable, /, *, key=None, reverse=False)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • list.sort
  • reversed
  • key

Source: Built-in Functions — Python 3.15.2 documentation. Checked 2026-11-03.