Checkinjg for higest four variables among eight

I'm trying to check what the four higest variables are among eight for an event. Is there a script call for that, or do i need to use 63 conditinal branches? or do i need to add all the other variables together, and then multiply the variable checked by 7?
@Oddball Do you need to know what variable each value is in, or do you only want the four highest numbers?
Four highest out of eight variables

Edit: Actually, i think to avoid tie errors, it should probably check the lowest out of the four, and return vaild whichever variables are equal to or higher than it. Then it can turn on the four events that are needed out of the eight possible
@Oddball Well, the following scriplet will return the four highest numbers out of the eight variables :

Code:
# 'v_id' is the start point; the ID of the first of eight variables
# 's_id' is the ID of the variable where you would like to save the four highest numbers

data = $game_variables.instance_variable_get(:@data)
data = data.slice(v_id, 8).sort {|x,y| -(x <=> y)}.take(4)
$game_variables[s_id] = data



# The data is saved as an array with four entries
# You can then access each of the highest numbers ...
$game_variables[s_id][n_id]

# Examples :
$game_variables[68][0]
$game_variables[68][1]
$game_variables[68][2]
$game_variables[68][3]
So this will save the four highest out of eight?
@Oddball Yeap. Now, I am making the assumption that the eight variables are all in a row. The code above will start at the first variable and copy the next seven variables into a temporary array which is then sorted by highest to lowest. The top four are then stored into another variable.
I'm not sure how Ossra's script work, but here is my version.
Code:
id = [1,2,3,4,5,6,7,8] # <-- variable ID you want to check
val = id.collect {|v| $game_variables[v]}.sort {|a,b| b <=> a}[0..3] # take index 0 up to 3
$game_variables[s_id] = val
Works exactly like Ossra's version but you don't need to specify start point, just throw the variable id.
Going to use TheoAllen's scriptlet. Will give credit once game is release. thank you!

Original thread: https://forums.rpgmakerweb.com/threads/checkinjg-for-higest-four-variables-among-eight.113658/