AI engineering glossary · Python core
What is sorted?
sorted: A built-in function that returns a new sorted list from any iterable, leaving the original untouched. It accepts a key function to choose what to sort by and reverse=True for descending order. The sort is stable.
sorted: an example
sorted([3, 1, 2]) gives [1, 2, 3]; sorted(names, key=len, reverse=True) puts the longest names first.
Related terms
More Python core terms
Where you learn it
sorted is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.