sort an array in python code example
Example 1: python sort list in reverse
list.sort(reverse=True)
sorted(list, reverse=True)
Example 2: sort array python
array = [1, 2, 3, 19, 11, 90, 0]
array.sort()
print(array)
Example 3: numpy sort
>>> a = np.array([[1,4],[3,1]])
>>> np.sort(a)
array([[1, 4],
[1, 3]])
>>> np.sort(a, axis=None)
array([1, 1, 3, 4])
>>> np.sort(a, axis=0)
array([[1, 1],
[3, 4]])
Example 4: sort an array python
myList = [1,5,3,4]
myList.sort()
print(myList)
Example 5: sorting python array
sorted(list, key=..., reverse=...)
Example 6: how to sort a list in python
l=[1,3,2,5]
l= sorted(l)
print(l)
l=[1,3,2,5]
l= sorted(l,reverse=True)
print(l)