84. Python Program to Sort the elements in Descending Oder.
How does this program work?
- This program is used to Sort the elements in Descending Oder using Python.
- In this program, an array of elements can be sorted without using any sorting function in PHP.
- Each element is compared with the next element, If the element is less than the other in comparison then the elements are swapped.
- After doing this for each element of the given array, then we get the elements in descending order.
Here is the code
a = list()
number = int(input( "Enter the number of elements you want: "))
print ('Enter numbers in array: ')
for i in range(int(number)):
n = input( "number : ")
a.append(int(n))
a.sort(reverse = True)
print( "Elements in descending order: ",a)