Course
Simulator
More
Premium
Log in
Python Function Reference
Functions
sorted
sorted
Return a new sorted list from the items in iterable.
Python 3.13
sorted
(
iterable
,
*
,
key
=
None
,
reverse
=
False
)
iterable
The iterable to sort.
key
A function to serve as a key for the sort comparison.
reverse
Sort in reverse order.
Examples
Python 3.13
>>
>
sorted
(
[
3
,
1
,
4
,
1
,
5
,
9
]
)
[
1
,
1
,
3
,
4
,
5
,
9
]