Reading sensors, adding to an array, sorting and doing something with the array.

Hi all,

I have a small project that I could use help understanding how best to move forward.

I have a set of 8 batteries of different voltages and age.
I’d like to read the voltages of all, assign an identifier to each battery , store those voltages in an array (I assume), then sort the array from the highest voltage to the lowest, pick the top 4 highest voltage batteries, and then “do something” (like light a led next to each of those 4 batteries indicating the top 4 highest voltages).

Although I’m quite a Arduino newbie, I do know how to read the battery voltages. The rest I have a vague idea but really stumbling with how to sort and then do something with the curated sorted list.

Thanks for any help or guidance!

The rest I have a vague idea but really stumbling with how to sort and then do something with the curated sorted list.

The code you posted doesn't have an array that needs to be sorted. Until you have an array, writing code to sort it is pointless. When you do, it is trivial.