check if list is in ascending order python

n = list(map(int, input().split())) #assign list values from input
if sorted(n) == n: #for descending, use sorted(n, reverse=True)
  print("Yes")
else:
  print("No")
  
#Hope this helps:)

Here is what the above code is Doing:
1. It takes the input and splits it into a list of integers.
2. It then checks if the list is sorted in ascending order.
3. If it is, it prints “Yes”, else it prints “No”.

The sorted() function takes two arguments:
1. The list to be sorted.
2. A boolean value which is True by default.

If the boolean value is True, the list is sorted in ascending order.
If the boolean value is False, the list is sorted in descending order.

For example:

sorted([1, 2, 3, 4, 5])
[1, 2, 3, 4, 5]

sorted([1, 2, 3, 4, 5], reverse=True)
[5, 4, 3, 2, 1]

sorted([1, 2, 3, 4, 5], reverse=False)
[1, 2, 3, 4, 5]

sorted([1, 2, 3, 4, 5], reverse=True) == sorted([1, 2, 3, 4, 5], reverse=False)
False

sorted([1, 2, 3, 4, 5]) == sorted([1, 2, 3, 4, 5], reverse=False)
True

sorted([1, 2, 3, 4, 5], reverse=True) == sorted([1, 2, 3, 4, 5])
False

sorted([1, 2, 3, 4, 5], reverse=False) == sorted([1, 2, 3, 4, 5])
True

sorted([1, 2, 3, 4, 5], reverse=True) == sorted([1, 2, 3, 4, 5], reverse=True)
True

sorted([1, 2, 3, 4, 5], reverse=False) == sorted([1, 2, 3, 4, 5], reverse=False)
True

sorted([1, 2, 3, 4, 5], reverse=True) == sorted([1, 2, 3, 4, 5], reverse=False)
False

sorted([1, 2, 3, 4, 5], reverse=False) == sorted([1, 2, 3, 4, 5], reverse=True)
False

sorted([1, 2, 3, 4, 5]) == sorted([1, 2, 3, 4, 5], reverse=True)
False

sorted([1, 2, 3, 4, 5], reverse=False) == sorted([1, 2, 3, 4, 5])
True

sorted([1, 2, 3, 4, 5], reverse=True) == sorted([1, 2, 3, 4, 5])
False

sorted([1, 2, 3, 4, 5]) == sorted([1, 2, 3, 4, 5])
True

sorted([1, 2, 3, 4, 5], reverse=True) == sorted([1, 2, 3, 4, 5], reverse=True)
True

sorted([1, 2, 3, 4, 5], reverse=False) == sorted([1, 2, 3, 4, 5], reverse=False)
True

sorted([1, 2, 3, 4, 5], reverse=True) == sorted([1, 2, 3, 4, 5], reverse=False)
False

sorted([1, 2, 3, 4, 5], reverse=False) == sorted([1, 2, 3, 4, 5], reverse=True)
False

sorted([1, 2, 3, 4, 5]) == sorted([1