Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random as rnd
- def verificar(arreglo):
- for i in range(0,len(arreglo)-1):
- if arreglo[i]>arreglo[i+1]:
- return False
- return True
- def ordenar(arreglo):
- while not(verificar(arreglo)):
- posA = rnd.randint(0, len(arreglo)-1)
- posB = rnd.randint(0, len(arreglo)-1)
- aux = arreglo[posA]
- arreglo[posA] = arreglo[posB]
- arreglo[posB] = aux
- return arreglo
- arreglo = [4,5,1,2,3,9,8,10,-1]
- print(ordenar(arreglo))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement