It's way more straight forward than that, each weapon have the same amount of max energy, and they recover energy all the same, but that's not the focus here :
in your example, since index 3 =1, it contains the lowest value of the four indexes here, how would I retain that index from comparing the array values?
Not sure I understand your example tbh
EDIT : I think I get how your method works but not sure, I'll have to experiment with it, thanks for the answer ~