83. Python Program to Sort the elements in Ascending Oder.
How does this program work?
- This program is used to Sort the elements in Ascending Oder using Python.
- In this program, an array of elements can be sorted without using any sorting function in Python.
- Each element is compared with the next element, If the element is greater 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 asceding 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()
print( "Elements in ascending order: ",a)