Quote by Studiot
Such a container has internal pressure P.
Expanding from P into a vacuum does no work.
Expanding from P against an external pressure P' < P does work, but as this happens P diminishes until P = P' when the system is in equilibrium.
How would you proceed from this equilibrium to infinity, where P = 0 ?

Yes, you would need initial pressure (P) greater than zero, and ambient pressure (P') equal to zero, i.e. in outer space. But the point remains, the statement that "entropy is a measure of energy unavailable for work" is contradicted by this example.