sorted() — Easy Examples
Returns a new sorted list from any iterable
Basic sorted() usage
Simple demonstration of the sorted() built-in function.
python
print(sorted([3, 1, 4, 1, 5])) print(sorted("python")) print(sorted([3, 1, 4], reverse=True))
sorted() is a built-in function that returns a new sorted list from any iterable.
sorted() with different inputs
Calling sorted() with various argument types.
python
# More sorted() examples print("sorted() is a Python built-in function") print(f"Type: {type(sorted)}")
sorted() accepts different types of arguments and produces corresponding results.
Want to try these examples interactively?
Open Easy Playground