sorted()
function is used to find the a sorted list from the given iterable in Python for the given input.
sorted()
function is a part of Python Built-in Functions.
Syntax of sorted()
Function
The syntax of
sorted()
function in Python is:
sorted(iterable[, key][, reverse])
Parameters of sorted()
Function in Python
x
– Where x
is any valid . This parameter is required.
Compatibility
sorted()
function is available and compatible with both Python 2.x
and 3.x
.
Return Value of sorted()
Function in Python
sorted()
function returns a sorted list from the given iterable for the given input.
Python sorted()
Function Example 1
Example CODE
Output:
Python sorted()
Function Example 2
Example CODE
Output: