Suppose we have a closed cylinder with a partition. In one chamber is a gas, in the other is nothing. Now suppose we quickly remove the partition. The gas expands freely without work being done. Thus the entropy increases, because the gas doesn't "lose" energy. So that explains how a gas increases its entropy during an expansion. But what about a compression. Suppose you slam the piston down on a gas faster than it can react. Then the proces is not quasistatic. So what is the work done on the gas in this case? If the entropy should increase it must be bigger than the work done in a quasistatic compression. But how does this happen?