Sensor filtering-hardware vs software

I am looking into filtering sensors for my arduino projects to provide more stable output, however, I was wondering whether anyone knows whether hardware or software filtering is better.
Does it depend on the sensor/vary with the type of sensor?

So for a potentiometer I could make a low pass filter with a resistor and capacitor on the potentiometer output line, or I could use an algorithm in software to do it instead. Is there a definitive answer on which method is better for a potentiometer?

What about a flex sensor and pressure sensor, which would be better for them or any other sensors in general.

The other thing is, how much processing power would it take to do software filtering? As the project I am working on is already using complementary filter for a couple of IMU's.

Thanks All

It is always a good idea to filter and stabilize the power supply to any electronic circuit (sensor). This is old news.
The output of analog sensors should be filtered when possible/neccecary.
If you need further filtering, do that in software.

Start with a stable supply. Use an RC type filter on the input with a time constant proportional to the response time of the sensor (you don’t want a 3 second time constant on something that changes at a 20hz rate). Further filtering along the lines of an “olympic average” works well in software. The key, though, is that all the pieces need to be there - there is no point using an rc filter, averaging software when your supply or reference for the sensor wanders all over giving bad readings. Just because you can calculate 3.675482 as the value does not mean it is anywhere near that if your reference/supply is a problem. For digital sensors (like the digital temp sensors etc.), you have to do the filtering in software, but you still need to make sure you have a stable reference to them.