WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Random array (https://forum.worldviz.com/showthread.php?t=2943)

CRI 09-05-2010 11:10 PM

Random array
 
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.
Code:

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



All times are GMT -7. The time now is 12:55 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC