I need to sort a list in python by following the steps.
Step 1: Import the randint definition of the random library of python.
Step 2: Take the elements of the list_1 as input.
Step 3: randomly choose two indexes i and j within the range of the size of list_1.
Step 4: Swap the elements present at the indexes i and j. After doing this, check whether the list_1 is sorted or not.
Step 5: Repeat step 3 and 4 until the array is not sorted.
In this i had completed upto step4 but i don not have a idea on how to check whethe a list is sorted my code here is.
import random
list_1=[int(x) for x in input().split()]
l=len(list_1)
while l!=0:
i=random.randint(1,l)
j=random.randint(1,l)
list_1[i], list_1[j] = list_1[j], list_1[i]