I thought I would chime into say that there is a perhaps easier way to see the reason for the outcomes questioned on stack exchange.
Say we have an ideal gas as the working substance. So, we know that the internal energy is a function only of temperature, and thus in an isothermal process the internal energy doesn't change. This means that by the first law we have:$$ \cancelto{0}{\Delta U } =Q-W \rightarrow Q=W$$
Now consider two processes that go from state 1 to state 2 isothermally. Process A is reversible and process B is irreversible. Entropy balances give:
$$\Delta S_A = \oint_{boundary} \,\frac{\delta Q_A}{T} + \cancelto{0}{\sigma_{genA} }$$
and
$$\Delta S_B = \oint_{boundary} \,\frac{\delta Q_B}{T} + \sigma_{genB} $$
Now since both processes occur between the same states, the
change in entropy for each must be the same. This gives us
$$\oint_{boundary} \,\frac{\delta Q_A}{T} = \oint_{boundary} \,\frac{\delta Q_B}{T} + \sigma_{genB} $$
Or, upon rearrangement (and since T is constant and the entropy generation term is strictly positive):
$$\oint_{boundary} \,\delta Q_A - \oint_{boundary} \,\delta Q_B = T \sigma_{genB} >0 \rightarrow Q_A - Q_B > 0$$
Recognizing that we can use the first law result above, we get:
$$W_A - W_B>0 \rightarrow W_A>W_B$$
And we are done.
Note that for a compression, work will be negative and so we see that less work input is required for a reversible compression. For an expansion, the work will be positive and so we see that more work output is obtained in a reversible expansion.
Just another way of looking at it.