sort() and sorted() in python code example
Example 1: sorted list python
sorted(iterable, key=None, reverse=False)
type(sorted(iterable, key=None, reverse=False)) = list
Example 2: sort python
>>> x = [1 ,11, 2, 3]
>>> y = sorted(x)
>>> x
[1, 11, 2, 3]
>>> y
[1, 2, 3, 11]
Example 3: sort in python'
arr = [1,4,2,7,5,6]
#sort in ascending order
arr = arr.sort()
#sort in descending order
arr = arr.sort(reverse = True)