Sign of work done by gas during isothermal expansion
If we imagine our proverbial, frictionless piston containing some ideal gas, when $P_{surr} &gt; P_{syst}$, the system is compressed by the piston and work is done on the system by the surroundings (i.e. work is positive). If the reverse is true ($P_{syst} &gt; P_{surr}$), the gas in the piston will expand and work is done on the surroundings by the system (work is negative)
If you think of it in terms of internal energy, it might help. When work is done on the system, the internal energy increases for the ideal gas in the system (work is positive, internal energy increases). When the system does work on the surroundings (expansion), its ability to do work decreases (internal energy decreases, work is negative).
Hope this helps.