mardi 18 août 2020

Generate a random number array that is not sorted [closed]

In python, I know how to generate a random number array like this

for i in range(arr_length):
    arr[i] = random.randrange(range)

But how can I make it so that when it generates the array, it is not sorted? When I try to generate a random array with a small length, for example, length "4", it sometimes generates the array so that it is sorted. Also, I'm trying to make it so that duplicate elements are allowed when generating the numbers.




Aucun commentaire:

Enregistrer un commentaire