Say I put a bunch of powerful square magnets on a nearly frictionless table in a disordered fashion. The second law of thermodynamics states that the system shall spontaneously get more disordered, yet the magnets will attract each other and form a chain (typically), thereby increasing the order of the system-and, seemingly, decreasing its entropy.
It would seem to me that the system is closed and the lattice is indeed the equilibrium state. Therefore, I suspect that by attracting each other, the magnets increase their own entropy by a larger amount than the decrease in entropy caused by the lattice formation. Is it true? If yes, what are the thermodynamics of magnets responsible for this? Is there a microscopic explanation?