#### Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy. Resolved by DJ Sures!

## Putting Random Numbers In Order

I am writing code that selects 6 random numbers and then i want to put them/say them in numerical order. I've got the number selection working OK but then putting them in numerical order is the tricky part. I've got it so it will select the lowest number from all the numbers but I've hit a road block selecting the next lowest number.

Here's what I've got so far;

#### `Code:`

``\$number1 = Getrandomunique(1,50)Say(\$number1):2\$number2 = Getrandomunique(1,50)if (\$number2 =\$number1)goto(2)elseSay(\$number2)endif:3\$number3 = Getrandomunique(1,50)if (\$number3 = \$number1 or \$number3 = \$number2)goto(3)elseSay(\$number3)endif:4\$number4 = Getrandomunique(1,50)if (\$number4 = \$number1 or \$number4 = \$number2 or \$number4 = \$number3)goto(4)elseSay(\$number4)endif:5\$number5 = Getrandomunique(1,50)if (\$number5 = \$number1 or \$number5 = \$number2 or \$number5 = \$number3 or \$number5 = \$number4)goto(5)elseSay(\$number5)endif:6\$number6 = Getrandomunique(1,50)if (\$number6 = \$number1 or \$number6 = \$number2 or \$number6 = \$number3 or \$number6 = \$number4 or \$number6 = \$number5)goto(6)elseSay(\$number6)endifPrint(\$number1)Print(\$number2)Print(\$number3)Print(\$number4)Print(\$number5)Print(\$number6)Print(\$number7)#\$response1 = X#Say in order#This part worksif(\$number1 < \$number2 and \$number1 < \$number3 and \$number1 < \$number4 and \$number1 < \$number5 and \$number1 < \$number6)say(\$number1)\$number1 = \$numberA #not sure about this for the next numberprint(\$numberA) #always prints a number not in the listelseif(\$number2 < \$number1 and \$number2 < \$number3 and \$number2 < \$number4 and \$number2 < \$number5 and \$number2 < \$number6)Say(\$number2)\$number2 = \$numberAPrint(\$numberA)elseif(\$number3 < \$number1 and \$number3 < \$number2 and \$number3 < \$number4 and \$number3 < \$number5 and \$number3 < \$number6)Say(\$number3)\$number3 = \$numberAPrint(\$numberA)elseif(\$number4 < \$number1 and \$number4 < \$number2 and \$number4 < \$number3 and \$number4 < \$number5 and \$number4 < \$number6)Say(\$number4)\$number4 = \$numberAPrint(\$numberA)elseif(\$number5 < \$number1 and \$number5 < \$number2 and \$number5 < \$number3 and \$number5 < \$number4 and \$number5 < \$number6)Say(\$number5)\$number5 = \$numberAPrint(\$numberA)elseif(\$number6 < \$number1 and \$number6 < \$number2 and \$number6 < \$number3 and \$number6 < \$number4 and \$number6 < \$number5)Say(\$number6)\$number6 = \$numberAprint(\$numberA)endif#this part is not workingif( \$number1 > \$numberA and \$number1 < \$number2 and \$number1 < \$number3 and \$number1 < \$number4 and \$number1 < \$number5 and \$number1 < \$number6)say(\$number1)elseif( \$number2 > \$numberA and \$number2 < \$number1 and \$number2 < \$number3 and \$number2 < \$number4 and \$number2 < \$number5 and \$number2 < \$number6 )Say(\$number2)Elseif( \$number3 > \$numberA and \$number3 < \$number1 and \$number3 < \$number2 and \$number3 < \$number4 and \$number3 < \$number5 and \$number3 < \$number6)Say(\$number3)#print(\$number) endif``

Any thoughts on how to get me going on the right track? I'm also hoping there may be a way the condense this.

Thanks

### Upgrade to ARC Pro

Get access to the latest features and updates before they're released. You'll have everything that's needed to unleash your robot's potential! Related Content
Synthiam
Based on your post activity, we found some content that may be interesting to you. Explore these other tutorials and community conversations.
#1
Use this plugin that i created for you: https://synthiam.com/redirect/legacy?table=plugin&id=41

Here is an example of how to use it...

`Code:definearray(\$numbers, 6)\$numbers = GetRandomUnique(0, 100)\$numbers = GetRandomUnique(0, 100)\$numbers = GetRandomUnique(0, 100)\$numbers = GetRandomUnique(0, 100)\$numbers = GetRandomUnique(0, 100)\$numbers = GetRandomUnique(0, 100)ControlCommand("SortArray", "\$numbers", "ascending")`
#2
Thanks DJ, I'll try that out.
#3
Thanks again DJ, by using the plugin you provided, I've got my code doing exactly what I wanted it to do. I learn something new here almost everyday!
#4
Awesome I publish all my plugins OpenSource if anyone is interested to see how they're created to make their own. Many of you have been in EZ-Script for a long time and it's getting to the point where graduation to C# and making custom controls is near 