In simpler words:In 1867 James Clerk Maxwell wrote:But if we conceive of a being whose faculties are so sharpened that he can follow every molecule in its course, such a being, whose attributes are as essentially finite as our own, would be able to do what is impossible to us. For we have seen that molecules in a vessel full of air at uniform temperature are moving with velocities by no means uniform, though the mean velocity of any great number of them, arbitrarily selected, is almost exactly uniform. Now let us suppose that such a vessel is divided into two portions, A and B, by a division in which there is a small hole, and that a being, who can see the individual molecules, opens and closes this hole, so as to allow only the swifter molecules to pass from A to B, and only the slower molecules to pass from B to A. He will thus, without expenditure of work, raise the temperature of B and lower that of A, in contradiction to the second law of thermodynamics.
If a Maxwell's Demon could in reality sort faster warmer gas molecules from slower colder gas molecules then we would have the makings of a perpetual motion machine for we could use this separation of temperature to run a heat engine. The heat would then flow back from the hot side to the cold side.An imaginary demon is placed in a doorway in a partition in the middle of a box where he allows warmer gas molecules to pass in one direction and cooler molecules to pass in the other direction. Soon one side is hot and the other side cold violating the second law of thermodynamics.
If a mechanical mechanism could cause two moving weights to change speeds spontaneously due to their own inertia and momentum so that one weight speeds up and the other weight slows down then we would have a mechanical Maxwell's Demon where the two weights are sorted into a faster moving weight and a slower moving weight. We would then have the makings of a perpetual motion machine for we could harness the inertial momentum of the faster weight against the inertial resistance of the slower weight in order to do work. The faster weight would then slow down as the slower weight is sped up resulting in both weights again moving at their original speeds. The cycle could then repeat endlessly.
When two weights spontaneously change speeds then no energy is added. When one weight accelerates to a faster speed while the other weight decelerates to a slower speed the total kinetic energy of the two weights is conserved, but their ectropy or usable energy is increased. This would be a mechanical equivalent to Maxwell's Demon. My belief is that a mechanism that increases ectropy can drive a perpetual motion machine without breaking any laws of physics.