Alright, so I created this program that uses four variables and gives each a random number between 3 and 10.

The problem is, I need the calculator to find out which number is 1st place, which is 2nd, 3rd, and 4th

I could do this if I had about an ounce of cocaine, a jillion If Then statements, and 3000bytes of ram to waste

So, I come to you guys, looking for an alternative.

Is there anyway for the calculator to put each variable in order from highest to lowest, and assign each a value (1,2,3 or 4) depending on which place it is in?

Yes, there is!

You need to create a list first, so assuming your variables are A B C and D, you would create list {A,B,C,D}. Then, use the SortD( command. It puts a list in order from highest to lowest.

```
:randInt(3,10→A
:randInt(3,10→B
:randInt(3,10→C
:randInt(3,10→D
:{A,B,C,D→L₁
:SortD(L₁
```

Now the numbers are in L

_{1}.

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

I'm awful with lists and matrices

How do you pull the numbers out of the list?

If you have a list L_{1} containing several values, here is how you get the "place" of each value.

`seq(sum(L _{1}≥L_{1}(X)),X,1,dim(L_{1}`

Try and figure out why this works; look up the commands on the wiki.

Okay, so I've got

```
:{A,B,C,D→L₁
:SortD(L₁
```

Now that they are in order, I need to assign values again to A, B, C, and D depending on the place in that order.

Would this code get the job done, or is there a more efficient way?

```
:If L₁(1)=A
:Then
:1→A
:End
//ect, for each variable and place
```

instead of making an if then statement, just make it a conditional

```
:if L₁(1)=A
:1→A
:if L₂(2)=B
:2→B
//ect.
```

Ok, I see what you mean. In that case, it is as simple as adding a second list. Create `L _{1}` as {A,B,C,D} and

`L`as {1,2,3,4}. Then, use the code.

_{2}SortD(L_{1},L_{2}

L_{2}(1→A

L_{2}(2→B

L_{2}(3→C

L_{2}(4→D

Timothy Foster - @tfAuroratide

Auroratide.com - Go here if you're nerdy like me

Thanks guys, I got my program up and running :)

Its a horse simulation game, pretty massive at a whopping 4k but its okay because I archive um' all and I like pretty stuff :D