#below is the program to print a list in sorted order. The sorting is done in the ascending order
my_list = [25,2,56,100,34,0]
my_list.sort()
print(my_list)
#To sort in the descending order use the below code
my_list.sort(reverse=True)
print(my_list)
#After above operations, my_list is modified directly. In cases where actual list must not be modified and modified list to be copied to new list, use the below code
my_list_1 = sorted(my_list)
print(my_list)
print(my_list_1)
0 Comments