I have four stats, all numeric, and I’ll be using their rankings fairly regularly. I need to know all four stats’ positions, so I was going to code a sequence that would set the best, second best, and worst (so then I’ve found the third-ranked stat by default). I’m planning to put this code in a subscene, since I’ll need it frequently.

The method I’m using now takes about a hundred lines, and it looks like this, only four times over in different iterations:

## Code

```
*if (((stat_a >= stat_b) and (stat_a >= stat_c)) and (stat_a >= stat_d))
*set best_stat "stat_a"
*if ((stat_b >= stat_c) and (stat_b >= stat_d))
*set second_stat "stat_b"
*if (stat_c >= stat_d)
*set worst_stat "stat_d"
*goto all_done
*else
*set worst_stat "stat_c"
*goto all_done
*elseif (stat_c >= stat_d)
*set second_stat "stat_c"
*if (stat_b >= stat_d)
*set worst_stat "stat_d"
*goto all_done
*else
*set worst_stat "stat_b"
*goto all_done
*else
*set second_stat "stat_d"
*if (stat_b >= stat_c)
*set worst_stat "stat_c"
*goto all_done
*else
*set worst_stat "stat_b"
*goto all_done
```

And so forth for stat_b and stat_c and stat_d, with a few minor variations to account for previous code.

I was just wondering if anyone had suggestions for how to code a simpler version? I feel like there must be a quicker solution, but after some tinkering, I’m still not sure what. I did have a hunt for a topic on this, but I didn’t find anything (apologies if I’ve just missed them).

Thanks!