PDA

View Full Version : Random array


CRI
09-05-2010, 11:10 PM
Is there any way I can create an array of

Continuous random sort it

thank all !!

Jeff
09-07-2010, 02:29 PM
You can use one of the functions from Python's random module to generate random numbers and place those in a list. Lists have a sort method you can use to sort the elements within.

import random
numbers = []
for i in range(1,10):
number = random.randint(1,10)
numbers.append(number)

print numbers
numbers.sort()
print numbers