Sonam
0
Q:

sorting in python

>>> x = [1 ,11, 2, 3]
>>> y = sorted(x)
>>> x
[1, 11, 2, 3]
>>> y
[1, 2, 3, 11]
2

a = (1, 11, 2)
x = sorted(a)
print(x)
 
4
sorted(list, key=..., reverse=...)
3
arr = [1,4,2,7,5,6]
#sort in ascending order
arr = arr.sort() 

#sort in descending order
arr = arr.sort(reverse = True)
1
python list sort()
0

New to Communities?

Join the community