Sound Following Servo

basically im trying to make a sound following servo to start with using 5 electret mics and some op amps what im trying to figure out is how to program this while taking up the least amount of ram on the arduino that being said i want to take the five inputs from the mic and compare them and choose which is larger or if 2 of them are approximately the same

in a nutshell what i want to do is
if M1 > M2,M3, M4,M5 goto position 1
if (M1 ? M2) > M3, M4,M5 goto position 2
if M2 > M1,M3, M4,M5 goto position 3
if (M2 ? M3) > M1, M4,M5 goto position 4
if M3 > M2,M1, M4,M5 goto position 5
if (M3 ? M4) > M1, M2,M5 goto position 6
if M4 > M2,M3, M1,M5 goto position 7
if (M4 ? M5) > M3, M1,M2 goto position 8
if M5 > M2,M3, M4,M1 goto position 9

if anyone has any better ideas then a bunch of if statements and nested if statements it would be much appreciated for 2 reasons one i want to save on memory and 2 i really dont want to write all those if statements lol

Without fitting a quadratic through the 5 mics, you should probably do M1, average of M1 M2, M2, average of M2 M3, M3 ... There are 9 values and you pick the largest and turn to that direction.

If you think of them as M[0] etc, arrays and for loops will simplify things.