digitalSmooth problems

but you may be on to something, the i value is not unique for each sensor.

That would be a problem. You'll need to make i an input to the function, and use three global variables.

Since the whole sorted array is re-written each time the function is called, I don't think static for it is appropriate.